結果
| 問題 |
No.2903 A Round-the-World Trip with the Tent
|
| コンテスト | |
| ユーザー |
vwxyz
|
| 提出日時 | 2024-09-27 21:09:23 |
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 1,893 ms / 2,000 ms |
| コード長 | 736 bytes |
| コンパイル時間 | 941 ms |
| コンパイル使用メモリ | 100,844 KB |
| 実行使用メモリ | 191,872 KB |
| 最終ジャッジ日時 | 2024-09-27 21:09:54 |
| 合計ジャッジ時間 | 22,231 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 42 |
ソースコード
#include <iostream>
#include <vector>
#include <cmath>
using namespace std;
#define int long long
const int MOD = 998244353;
signed main() {
int N;
long long K; // K is long long
cin >> K >> N;
vector<vector<int>> D(N + 1);
for (int d = 1; d <= N; ++d) {
for (int n = 2 * d; n <= N; n += d) {
D[n].push_back(d);
}
}
long long pow2=2;
vector<int> dp(N + 1, 0);
for (int n = 1; n <= N; ++n) {
dp[n] = pow2 % MOD;
pow2*=2;
pow2%=MOD;
if (K > 1) {
dp[n] += 1;
}
for (int d : D[n]) {
dp[n] = (dp[n] - dp[d] + MOD) % MOD;
}
}
int ans = dp[N];
cout << ans << endl;
return 0;
}
vwxyz