Test instructions: The topic gives a Euler function value f (x), let's ask >= the minimum number N of this function value, so that f (N) >= f (x);
Analysis: There are two ways to do this topic. First, the brute force forms the Euler function table, then adjusts it to order, and then builds a new table to record the minimum Euler value that satisfies the condition.
The second, according to the properties of Euler functions, for a prime n,f (N) = N-1; Then assume that the first prime greater than N is M, its function value is M-1, at this time, any number between (N,M) is composite, and their Euler value must be less than M-1, so we want to find the minimum number of the problem, can be found from the number of the first one, until we find the initial prime, This number is the minimum value we are looking for.
Note: C + + compiler does not support%i64, only support%LLD, I because of this WA a few times, pay attention to compiler requirements and the description above the topic.
The code is as follows:
#include <iostream>#include<cstdio>#include<cstring>using namespacestd;#defineMAXN 1500100#defineLL Long LongLL PRIME[MAXN+ -];voidMake () {memset (prime,1,sizeof(prime)); prime[1] =0; for(inti =2; I <= MAXN; i++) { if(Prime[i]) { for(intj = i*2; J <= Maxn; J + =i) {prime[j]=0; } } }}intMain () {LL T,n,num,ca=0; Make (); LL sum; scanf ("%lld",&t); while(t--) {scanf ("%lld",&N); Sum=0; for(inti =0; I < n; i++) {scanf ("%lld",&num); for(LL j = num+1;true; J + +) { if(Prime[j]) {//printf ("the min one =%d\n", j);Sum + =J; Break; }}} printf ("Case %LLD:",++CA); printf ("%lld xukha\n", sum); } return 0;}
Lightoj 1370 Bi-shoe and Phi-shoe (Euler function)