Because all integers can be uniquely decomposed, P1^a1*p2^a2*...*pi^ai, and the number of queries can be decomposed into P1^a1k*p2^a2k*...*pi^aik, this inquiry will all a1>=a1k && A2 >= A2K &&
The number of A3 >= a3k is separated from the original set. The AI represents the power of the Pi.
Then the number can be determined only if the maximum power of the element factor is queried once. So the answer is that all the numbers of only one factor that are not greater than N.
#include <bits/stdc++.h>using namespacestd;Const intMAXN = 1e3+5;intPRIME[MAXN];BOOLVIS[MAXN];intSieveintN) { intm = sqrt (n+0.5); for(inti =2; I <= m; i++)if(!Vis[i]) { for(intj = i*i; J <= N; j+=i) Vis[j] =true; } intc =0; for(inti =2; I <= N; i++)if(!Vis[i]) {Prime[c++] =i; } returnC;} Vector<int>ans;intMain () {inttot = Sieve ( +); intN scanf"%d",&N); for(inti =0; i < tot; i++){ intp =Prime[i]; if(P > N) Break; for(intt = P; t<=n; t*=p) {ans.push_back (t); }} printf ("%d\n", Ans.size ()); for(inti =0; I < ans.size (); i++){ if(i) Putchar (' '); printf ("%d", Ans[i]); } return 0;}
Codeforces Round #319 (Div. 2) C Vasya and Petya ' s Game