提出 #67551603
ソースコード 拡げる
#include <bits/stdc++.h>
using namespace std;
// b != c
// a == c when b > a
// b > a is bad
// a divides into b is bad
const long long MOD = 998244353;
const long long inv2 = MOD / 2 + 1;
const long long lim = 2000000;
long long mult(long long a, long long b) {
return (a % MOD) * (b % MOD) % MOD;
}
long long sub(long long a, long long b) {
return ((a - (b % MOD)) % MOD + MOD) % MOD;
}
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
long long N;
cin >> N;
long long ans = mult(N, N + 1);
ans = mult(ans, inv2);
for (int i= 1; i <= lim; i++) {
ans = sub(ans, N / i);
}
for (int k = 1; k <= lim; k++) {
long long lb = N / (k + 1);
lb++;
lb = max(lim + 1, lb);
long long amt = N / k - lb + 1;
amt = max(0LL, amt);
ans = sub(ans, mult(k, amt));
}
cout << ans << "\n";
}
提出情報
| 提出日時 | |
|---|---|
| 問題 | E - Count A%B=C |
| ユーザ | AQT |
| 言語 | C++ 20 (gcc 12.2) |
| 得点 | 475 |
| コード長 | 923 Byte |
| 結果 | AC |
| 実行時間 | 26 ms |
| メモリ | 3636 KiB |
ジャッジ結果
| セット名 | Sample | All | ||||
|---|---|---|---|---|---|---|
| 得点 / 配点 | 0 / 0 | 475 / 475 | ||||
| 結果 |
|
|
| セット名 | テストケース |
|---|---|
| Sample | 00-sample-01.txt, 00-sample-02.txt, 00-sample-03.txt |
| All | 00-sample-01.txt, 00-sample-02.txt, 00-sample-03.txt, 01-01.txt, 01-02.txt, 01-03.txt, 01-04.txt, 01-05.txt, 01-06.txt, 01-07.txt, 01-08.txt, 01-09.txt, 01-10.txt, 01-11.txt, 01-12.txt, 01-13.txt, 01-14.txt, 01-15.txt, 01-16.txt, 01-17.txt, 01-18.txt, 01-19.txt, 01-20.txt, 01-21.txt, 01-22.txt, 01-23.txt, 01-24.txt, 01-25.txt, 01-26.txt, 01-27.txt, 01-28.txt, 01-29.txt, 01-30.txt, 01-31.txt, 01-32.txt, 01-33.txt, 01-34.txt, 01-35.txt, 01-36.txt, 01-37.txt, 01-38.txt, 01-39.txt, 01-40.txt, 01-41.txt, 01-42.txt, 01-43.txt, 01-44.txt, 01-45.txt, 01-46.txt, 01-47.txt, 01-48.txt, 01-49.txt, 01-50.txt, 01-51.txt, 01-52.txt, 01-53.txt |
| ケース名 | 結果 | 実行時間 | メモリ |
|---|---|---|---|
| 00-sample-01.txt | AC | 25 ms | 3456 KiB |
| 00-sample-02.txt | AC | 25 ms | 3512 KiB |
| 00-sample-03.txt | AC | 25 ms | 3504 KiB |
| 01-01.txt | AC | 25 ms | 3512 KiB |
| 01-02.txt | AC | 25 ms | 3508 KiB |
| 01-03.txt | AC | 25 ms | 3508 KiB |
| 01-04.txt | AC | 25 ms | 3628 KiB |
| 01-05.txt | AC | 25 ms | 3520 KiB |
| 01-06.txt | AC | 25 ms | 3388 KiB |
| 01-07.txt | AC | 25 ms | 3480 KiB |
| 01-08.txt | AC | 25 ms | 3456 KiB |
| 01-09.txt | AC | 25 ms | 3512 KiB |
| 01-10.txt | AC | 25 ms | 3508 KiB |
| 01-11.txt | AC | 25 ms | 3508 KiB |
| 01-12.txt | AC | 25 ms | 3412 KiB |
| 01-13.txt | AC | 25 ms | 3516 KiB |
| 01-14.txt | AC | 25 ms | 3508 KiB |
| 01-15.txt | AC | 25 ms | 3508 KiB |
| 01-16.txt | AC | 25 ms | 3512 KiB |
| 01-17.txt | AC | 25 ms | 3508 KiB |
| 01-18.txt | AC | 25 ms | 3472 KiB |
| 01-19.txt | AC | 25 ms | 3516 KiB |
| 01-20.txt | AC | 25 ms | 3516 KiB |
| 01-21.txt | AC | 26 ms | 3508 KiB |
| 01-22.txt | AC | 25 ms | 3512 KiB |
| 01-23.txt | AC | 25 ms | 3428 KiB |
| 01-24.txt | AC | 25 ms | 3584 KiB |
| 01-25.txt | AC | 25 ms | 3512 KiB |
| 01-26.txt | AC | 25 ms | 3504 KiB |
| 01-27.txt | AC | 25 ms | 3636 KiB |
| 01-28.txt | AC | 25 ms | 3444 KiB |
| 01-29.txt | AC | 25 ms | 3512 KiB |
| 01-30.txt | AC | 25 ms | 3456 KiB |
| 01-31.txt | AC | 25 ms | 3576 KiB |
| 01-32.txt | AC | 25 ms | 3488 KiB |
| 01-33.txt | AC | 25 ms | 3516 KiB |
| 01-34.txt | AC | 25 ms | 3512 KiB |
| 01-35.txt | AC | 25 ms | 3516 KiB |
| 01-36.txt | AC | 25 ms | 3580 KiB |
| 01-37.txt | AC | 25 ms | 3516 KiB |
| 01-38.txt | AC | 25 ms | 3600 KiB |
| 01-39.txt | AC | 25 ms | 3628 KiB |
| 01-40.txt | AC | 25 ms | 3512 KiB |
| 01-41.txt | AC | 25 ms | 3416 KiB |
| 01-42.txt | AC | 25 ms | 3512 KiB |
| 01-43.txt | AC | 25 ms | 3596 KiB |
| 01-44.txt | AC | 25 ms | 3388 KiB |
| 01-45.txt | AC | 25 ms | 3412 KiB |
| 01-46.txt | AC | 25 ms | 3516 KiB |
| 01-47.txt | AC | 25 ms | 3456 KiB |
| 01-48.txt | AC | 25 ms | 3512 KiB |
| 01-49.txt | AC | 25 ms | 3520 KiB |
| 01-50.txt | AC | 25 ms | 3508 KiB |
| 01-51.txt | AC | 25 ms | 3512 KiB |
| 01-52.txt | AC | 25 ms | 3504 KiB |
| 01-53.txt | AC | 25 ms | 3392 KiB |