Submission #9452

#TimeUsernameProblemLanguageResultExecution timeMemory
9452lemonsqueezeXtreme gcd sum (kriii2_X)C++98
0 / 4
0 ms16868 KiB
#include <cstdio> const int N = 10000; const int NUMERIC = 2000000; typedef long long int64; const int64 MOD = 1000000007; int n; int64 a[N], b[N], d[NUMERIC]; int main(void) { scanf("%d", &n); for (int i = 0; i < n; i++) scanf("%lld %lld", &a[i], &b[i]); for (int i = 7; i >= 1; i--) { int64 cnt = 1; for (int j = 0; j < n; j++) { int bdiv = b[j] / i; int adiv = (a[j] - 1) / i; int64 tmpcnt = (bdiv - adiv); cnt = (cnt * tmpcnt) % MOD; } d[i] = cnt; for (int j = i + i; j <= 7; j+=i) { d[i] = (d[i] - d[j] + MOD) % MOD; } } int64 ans = 0; for (int i = 1; i <= 7; i++) { ans += (int64) i * d[i]; ans = ans % MOD; } printf("%lld\n", ans); return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...