标签:des style http os 文件 io for re
思路:n|(x+1)*(x-1),设n=a*b,当a|(x-1)时验证b|(x+1),或者当a|(x+1)时验证b|(x-1).
#include <cstdio> #include <iostream> #include <algorithm> #include <cmath> #include <cstring> #include <stdlib.h> #include <set> using namespace std; int main(){ int n; scanf("%d",&n); set<int> s; int sum=(int)sqrt(n); for(int a=1;a<=sum;a++){ if(n%a==0){ int b=n/a; for(int x=1;x<=n;x+=b){ if((x+1)%a==0){ s.insert(x); } } for(int x=b-1;x<=n;x+=b){ if((x-1)%a==0){ s.insert(x); } } } } if(s.empty()) puts("None"); while(!s.empty()){ printf("%d\n",*s.begin()); s.erase(s.begin()); } return 0; }
标签:des style http os 文件 io for re
原文地址:http://blog.csdn.net/kimi_r_17/article/details/38087577