题目链接:http://poj.org/problem?id=1183
中文题目,不错,哈哈,不多说,拿笔画!
PS:用int会超时哦!
代码如下:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
| #include <iostream> #include <cstdio> #include <cstring> using namespace std; int main() { unsigned int m,n,a,sum; while(cin>>a) { m=a; while(1) { if((a*a+1)%m==0) break; m++; } n=(a*a+1)/m; sum=2*a+m+n; cout<<sum<<endl; } }
|