結果
| 問題 | No.2903 A Round-the-World Trip with the Tent |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2025-07-04 00:13:11 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 46 ms / 2,000 ms |
| コード長 | 993 bytes |
| コンパイル時間 | 2,334 ms |
| コンパイル使用メモリ | 194,488 KB |
| 実行使用メモリ | 11,388 KB |
| 最終ジャッジ日時 | 2025-07-04 00:13:16 |
| 合計ジャッジ時間 | 4,608 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 42 |
ソースコード
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using pii=pair<int,int>;
#define all(a) a.begin(),a.end()
#define pb push_back
#define sz(a) ((int)a.size())
const int N=1000005,mod=998244353;
int add(int x, int y){x+=y; if(x>=mod) x-=mod; return x;}
int sub(int x, int y){x-=y; if(x<0) x+=mod; return x;}
int mul(int x, int y){return ((ll)x)*y%mod;}
ll k;
int n,mu[N],pw2[N];
void amano_hina_is_the_goat(){
cin >> k >> n;
mu[1]=1;
for(int i=1; i<=n; ++i){
for(int j=i*2; j<=n; j+=i) mu[j]=sub(mu[j],mu[i]);
}
pw2[0]=1;
for(int i=1; i<=n; ++i) pw2[i]=add(pw2[i-1],pw2[i-1]);
int res=0;
for(int i=1; i<=n; ++i) if(n%i==0){
int cnt=pw2[n/i];
if(k==1);
else cnt=add(cnt,1);
res=add(res,mul(mu[i],cnt));
}
cout << res << "\n";
}
signed main(){
ios_base::sync_with_stdio(0),cin.tie(0);
cout << fixed << setprecision(20);
int t=1; //cin >> t;
while(t--) amano_hina_is_the_goat();
}