結果
問題 | No.1396 Giri |
ユーザー | chestnut_68 |
提出日時 | 2021-02-14 21:34:19 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 28 ms / 2,000 ms |
コード長 | 640 bytes |
コンパイル時間 | 1,558 ms |
コンパイル使用メモリ | 174,308 KB |
実行使用メモリ | 7,424 KB |
最終ジャッジ日時 | 2024-07-22 08:55:12 |
合計ジャッジ時間 | 2,988 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 23 |
ソースコード
#include <bits/stdc++.h> using namespace std; #define rep(i,n) for(int i=0;i<n;i++) const int64_t MOD=998244353LL; const int64_t MAX=1e6+1; set<int64_t> P; void Prime(){ vector<bool> B(MAX,true); B[0]=false; B[1]=false; for(int64_t i=2;i<MAX;i++){ if(B[i]){ P.insert(i); int64_t a=i; while(i*a<MAX){ B[i*a]=false; a++; } } } } int main(){ Prime(); int64_t N,c=0,ans=1;cin>>N; auto itr=P.upper_bound(N); itr--; int64_t K=*itr; for(auto i:P){ if(i==K)break; int64_t a=i,S=N; while(a<=N){ ans*=i; ans%=MOD; a*=i; } } cout<<ans<<endl; }