#include <iostream> #include <cstdio> #include <cstring> #include <algorithm> #define ll __int64 using namespace std; const int maxn = 500005; const ll mod = 1ll<<32; ll num[maxn], dp[maxn]; void cal() { for (ll i = 1; i < maxn; i++) for (ll j = i; j < maxn; j += i) num[j] += (j/i+1) * (j/i) / 2; } void init() { memset(num, 0, sizeof(num)); cal(); dp[1] = 1; for (ll i = 2; i < maxn; i++) { dp[i] = dp[i-1] + num[i]*i; dp[i] = dp[i] % mod; } } int main() { init(); int t, n, cas = 1; scanf("%d", &t); while (t--) { scanf("%d", &n); printf("Case #%d: %I64d\n", cas++, dp[n]); } return 0; } /* Main.cc:5:12: error: '__int64' does not name a type #define ll __int64 ^ Main.cc:8:7: note: in expansion of macro 'll' const ll mod = 1ll<<32; ^ Main.cc:5:12: error: '__int64' does not name a type #define ll __int64 ^ Main.cc:10:1: note: in expansion of macro 'll' ll num[maxn], dp[maxn]; ^ Main.cc: In function 'void cal()': Main.cc:5:12: error: '__int64' was not declared in this scope #define ll __int64 ^ Main.cc:13:7: note: in expansion of macro 'll' for (ll i = 1; i < maxn; i++) ^ Main.cc:13:17: error: 'i' was not declared in this scope for (ll i = 1; i < maxn; i++) ^ Main.cc:14:11: error: expected ';' before 'j' for (ll j = i; j < maxn; j += i) ^ Main.cc:14:18: error: 'j' was not declared in this scope for (ll j = i; j < maxn; j += i) ^ Main.cc:15:4: error: 'num' was not declared in this scope num[j] += (j/i+1) * (j/i) / 2; ^ Main.cc: In function 'void init()': Main.cc:19:9: error: 'num' was not declared in this scope memset(num, 0, sizeof(num)); ^ Main.cc:21:2: error: 'dp' was not declared in this scope dp[1] = 1; ^ Main.cc:5:12: error: '__int64' was not declared in this scope #define ll __int64 ^ Main.cc:22:7: note: in expansion of macro 'll' for (ll i = 2; i < maxn; i++) { ^ Main.cc:22:17: error: 'i' was not declared in this scope for (ll i = 2; i < maxn; i++) { ^ Main.cc:24:19: error: 'mod' was not declared in this scope dp[i] = dp[i] % mod; ^ Main.cc: In function 'int main()': Main.cc:34:38: error: 'dp' was not declared in this scope printf("Case #%d: %I64d\n", cas++, dp[n]); ^ */ |
Double click to view unformatted code.