#include<cstdio> #include<cmath> #include<algorithm> typedef long long lint; lint n,s; lint ans[131074],ap=0; int main(){ scanf("%lld",&n); if(n==1){ puts("None"); return 0; } s=sqrt(n); ans[ap++]=1; for(int i=1;i<=s;i++){ if(n%i==0){ lint c=n/i; for(lint b=c;b<=n;b+=c){ if((b+2)*b%n==0)ans[ap++]=b+1; if((b-2)*b%n==0)ans[ap++]=b-1; } } } std::sort(ans,ans+ap); printf("%lld\n",ans[0]); for(int i=1;i<ap&&ans[i]<n;i++){ if(ans[i]!=ans[i-1])printf("%lld\n",ans[i]); } return 0; }
原文:http://www.cnblogs.com/ccz181078/p/5218265.html