Description
Input
Output
Sample Input
3 2 10 20
Sample Output
1 822
#include <iostream> #include <cmath> using namespace std; int main() { int t,i,n,sum; double k; scanf("%d",&t); while(t--) { scanf("%d",&n); sum=1; k=sqrt((double)n); for(i=2;i<=k;i++) { if(n%i==0&&i!=n/i) { sum+=i; sum+=n/i; } else if(n%i==0) { sum+=i; } } printf("%d\n",sum); } return 0; }
原文地址:http://blog.csdn.net/zsc2014030403015/article/details/43484585