BZOJ1406[AHOI2007] Cipher Box
Test instructions
An integer that outputs 1 to n-1, and modulo n equals 1
Exercises
Set the number x, X+1 (x-1) =n*k, set n1*n2 equals K, (x+1)%n1==0, (x-1)%n2==0, so N1, N2 are the factor of N, and a ≤sqrt (n), a ≥ (sqrt (n)). It is said that the number within the int is no more than 30 factors, so the factor of all ≥SQRT (n) can be calculated first, and then for each factor, to find out the multiple of the factor of all
Code:
1#include <cstdio>2#include <cstring>3#include <algorithm>4#include <cmath>5 #defineInc (I,J,K) for (int i=j;i<=k;i++)6 #defineMAXN 1007 using namespacestd;8 9 intyss,ys[maxn],st[maxn* the],sts;Ten intMain () { One intN scanf"%d", &n); Inc (I,1,(int) sqrt (n))if(n%i==0) ys[++yss]=n/i; st[sts=1]=1; AInc (I,1, Yss) { - for(intj=ys[i];j<=n;j+=Ys[i]) { - if(J-2)% (n/ys[i]) = =0) st[++sts]=j-1; the if(j<n&& (j+2)% (n/ys[i]) = =0) st[++sts]=j+1; - } - } - if(sts==0|| n==1) printf ("None");Else{ +Sort (st+1, st+1+sts);intM=unique (st+1, st+1+sts)-st-1; Inc (I,1, m) printf ("%d\n", St[i]); - } + return 0; A}
20160603
BZOJ1406[AHOI2007] Cipher Box