标签:
#include<iostream> #include<cstring> #include<cstdio> #include<cmath> using namespace std; int an[510000],num; bool bn[510000]; void prime() { num = 0; memset(bn,1,sizeof(bn)); bn[0] = bn[1] = 0; int i,j; for(i = 2;i<=500000;i++) { if(bn[i]) an[num++] = i; for(j = 0;an[j]*i<=500000;j++) { if(i%an[j] == 0)break; bn[i*an[j]] = 0; } } } int main() { int z; prime(); cin>>z; while(z--) { int a; scanf("%d",&a); int aa = a; int i,j,k; int t,sum,ans = 1; for(i = 0;a!=1;i++) { if(a%an[i] == 0) { t = 1,sum = 1; while(a%an[i] == 0) { a/=an[i]; t *= an[i]; sum+=t; } ans *= sum; } } ans -= aa; printf("%d\n",ans); } return 0; }
标签:
原文地址:http://www.cnblogs.com/wos1239/p/4581642.html