結果
問題 | No.752 mod数列 |
ユーザー |
![]() |
提出日時 | 2018-11-09 22:11:20 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 693 bytes |
コンパイル時間 | 533 ms |
コンパイル使用メモリ | 70,400 KB |
実行使用メモリ | 81,772 KB |
最終ジャッジ日時 | 2024-11-21 06:03:32 |
合計ジャッジ時間 | 7,929 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 28 WA * 3 |
ソースコード
#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) ret += 1LL * (x - P) * 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;}