結果
問題 | No.2903 A Round-the-World Trip with the Tent |
ユーザー |
👑 |
提出日時 | 2023-08-30 18:32:52 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 22 ms / 2,000 ms |
コード長 | 661 bytes |
コンパイル時間 | 1,429 ms |
コンパイル使用メモリ | 174,004 KB |
実行使用メモリ | 7,296 KB |
最終ジャッジ日時 | 2024-09-27 19:30:15 |
合計ジャッジ時間 | 2,676 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 42 |
ソースコード
#include <bits/stdc++.h> using namespace std; #include <atcoder/modint> using namespace atcoder; using mint=modint998244353; int main(void) { long long k; int n; cin >> k >> n; vector<mint> ans(n+1,1); for(int i=1;i<=n;++i){ ans[i]=ans[i-1]*2; } vector<bool> prime(n+1,true); prime[0]=false; prime[1]=false; for(int i=2;i<=n;++i){ if(prime[i]){ for(int j=n/i;j>0;--j){ prime[i*j]=(j==1); ans[i*j]-=ans[j]; } } } if(k!=1 && n==1){ cout << (ans[n]+1).val() << endl; } else { cout << ans[n].val() << endl; } }