标签:
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 37249 Accepted Submission(s): 11625
#include <cstdio> #include <cstring> const int N = 500001; int num[N]; void Init(){ for(int i = 1; i < N; i++) num[i] = 1; for(int i = 2; i < N; i++) for(int j = i+i; j < N; j += i) num[j] += i; } void Sieve(){ //memset(num, 1, sizeof(num)); for(int i = 2; i < N; i++) for(int j = 2; i*j < N; j++) num[i*j] += j; } int main(){ int T; //Sieve(); Init(); scanf("%d", &T); while(T--){ int n; scanf("%d", &n); if(n == 1){ printf("0\n"); continue; } printf("%d\n", num[n]); } return 0; }
标签:
原文地址:http://www.cnblogs.com/fengshun/p/5077234.html