标签:present out scan tac chm namespace mem 枚举 while
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 262144/262144 K (Java/Others)
Total Submission(s): 872 Accepted Submission(s): 315
1 #include <iostream> 2 #include <string> 3 #include <cstdio> 4 #include <cstring> 5 #include <algorithm> 6 #include <climits> 7 #include <cmath> 8 #include <vector> 9 #include <queue> 10 #include <stack> 11 #include <set> 12 #include <map> 13 using namespace std; 14 typedef long long LL ; 15 typedef unsigned long long ULL ; 16 const int maxn = 1e5 + 10 ; 17 const int inf = 0x3f3f3f3f ; 18 const int npos = -1 ; 19 const int mod = 1e9 + 7 ; 20 const int mxx = 100 + 5 ; 21 const double eps = 1e-6 ; 22 const double PI = acos(-1.0) ; 23 24 ULL T, n, prime[maxn], nd, theta2; 25 bool vis[maxn]; 26 int tot, cnt; 27 void init(int top){ 28 tot=0; 29 memset(vis,true,sizeof(vis)); 30 for(int i=2;i<=top;i++){ 31 if(vis[i]){ 32 prime[tot++]=(ULL)i; 33 } 34 for(int j=0;j<tot&&(i*prime[j]<=top);j++){ 35 vis[i*prime[j]]=false; 36 if(i%prime[j]==0) 37 break; 38 } 39 } 40 } 41 int main(){ 42 // freopen("in.txt","r",stdin); 43 // freopen("out.txt","w",stdout); 44 init(1e5+1); 45 while(~scanf("%llu",&T)){ 46 while(T--){ 47 scanf("%llu",&n); 48 theta2=1ULL; 49 nd=n; 50 for(int i=0;i<tot && prime[i]*prime[i]<=n;i++) 51 if(n%prime[i]==0){ 52 ULL p=prime[i], alpha=0ULL; 53 ULL sigma=1ULL, square=1ULL; 54 while(n%p==0ULL){ 55 alpha++; 56 square*=p; 57 sigma+=square*square; 58 n/=p; 59 } 60 nd*=alpha+1ULL; 61 theta2*=sigma; 62 } 63 if(n>1){ 64 nd*=2ULL; 65 theta2*=(1ULL+n*n); 66 } 67 printf("%llu\n",theta2-nd); 68 } 69 } 70 return 0; 71 }
标签:present out scan tac chm namespace mem 枚举 while
原文地址:http://www.cnblogs.com/edward108/p/7636856.html