結果

問題 No.752 mod数列
ユーザー square1001square1001
提出日時 2018-11-09 22:13:07
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 716 bytes
コンパイル時間 926 ms
コンパイル使用メモリ 69,900 KB
実行使用メモリ 81,548 KB
最終ジャッジ日時 2023-08-13 11:37:58
合計ジャッジ時間 8,772 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 53 ms
81,420 KB
testcase_01 AC 53 ms
81,304 KB
testcase_02 AC 53 ms
81,364 KB
testcase_03 AC 53 ms
81,300 KB
testcase_04 AC 53 ms
81,412 KB
testcase_05 AC 53 ms
81,376 KB
testcase_06 AC 54 ms
81,304 KB
testcase_07 AC 53 ms
81,352 KB
testcase_08 AC 53 ms
81,408 KB
testcase_09 AC 53 ms
81,396 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 AC 232 ms
81,496 KB
testcase_16 AC 244 ms
81,368 KB
testcase_17 AC 376 ms
81,548 KB
testcase_18 AC 246 ms
81,440 KB
testcase_19 AC 321 ms
81,548 KB
testcase_20 AC 273 ms
81,376 KB
testcase_21 AC 273 ms
81,364 KB
testcase_22 AC 268 ms
81,428 KB
testcase_23 AC 342 ms
81,360 KB
testcase_24 AC 342 ms
81,404 KB
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 AC 439 ms
81,304 KB
testcase_31 AC 53 ms
81,360 KB
testcase_32 AC 53 ms
81,324 KB
testcase_33 AC 53 ms
81,396 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
int P, Q, L, R; long long s[10000009];
long long solve(int x) {
	if (x <= 10000000) return s[x + 1];
	long long ret = s[10000001];
	for (int i = 1; i <= 100; ++i) {
		int l = P / (i + 1), r = P / i;
		if (r <= 10000000 || l >= x) continue;
		l = max(l, 10000000);
		r = min(r, x);
		ret += 1LL * (P % r) * (r - l) + 1LL * i * (r - l) * (r - l - 1) / 2;
	}
	if (P < x && x > 10000000) ret += 1LL * (x - 10000000) * P;
	return ret;
}
int main() {
	cin >> P >> Q;
	for (int i = 1; i <= 10000000; ++i) {
		s[i + 1] = s[i] + P % i;
	}
	for (int i = 0; i < Q; ++i) {
		cin >> L >> R;
		cout << solve(R) - solve(L - 1) << '\n';
	}
	return 0;
}
0