답안 #9454

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
9454 2014-09-28T06:33:42 Z lemonsqueeze Xtreme gcd sum (kriii2_X) C++
1 / 4
4000 ms 16868 KB
#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 = 1000000; 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 <= 1000000; j+=i) {
			d[i] = (d[i] - d[j] + MOD) % MOD;
		}
	}
	int64 ans = 0;
	for (int i = 1; i <= 1000000; i++) {
		ans += (int64) i * d[i];
		ans = ans % MOD;
	}
	printf("%lld\n", ans);
	return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 192 ms 16868 KB Output is correct
2 Correct 192 ms 16868 KB Output is correct
3 Correct 188 ms 16868 KB Output is correct
4 Correct 212 ms 16868 KB Output is correct
5 Correct 212 ms 16868 KB Output is correct
6 Correct 216 ms 16868 KB Output is correct
7 Correct 244 ms 16868 KB Output is correct
8 Correct 252 ms 16868 KB Output is correct
9 Correct 260 ms 16868 KB Output is correct
10 Correct 248 ms 16868 KB Output is correct
11 Correct 428 ms 16868 KB Output is correct
12 Correct 432 ms 16868 KB Output is correct
13 Correct 436 ms 16868 KB Output is correct
14 Correct 428 ms 16868 KB Output is correct
15 Correct 432 ms 16868 KB Output is correct
16 Correct 432 ms 16868 KB Output is correct
17 Correct 424 ms 16868 KB Output is correct
18 Correct 432 ms 16868 KB Output is correct
19 Correct 432 ms 16868 KB Output is correct
20 Correct 432 ms 16868 KB Output is correct
21 Correct 432 ms 16868 KB Output is correct
22 Correct 428 ms 16868 KB Output is correct
23 Correct 428 ms 16868 KB Output is correct
24 Correct 436 ms 16868 KB Output is correct
25 Correct 432 ms 16868 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3128 ms 16868 KB Output is correct
2 Correct 3124 ms 16868 KB Output is correct
3 Correct 3124 ms 16868 KB Output is correct
4 Correct 3140 ms 16868 KB Output is correct
5 Correct 3132 ms 16868 KB Output is correct
6 Correct 3120 ms 16868 KB Output is correct
7 Correct 3120 ms 16868 KB Output is correct
8 Correct 3136 ms 16868 KB Output is correct
9 Correct 3136 ms 16868 KB Output is correct
10 Correct 3136 ms 16868 KB Output is correct
11 Execution timed out 4000 ms 16864 KB Program timed out
12 Halted 0 ms 0 KB -