結果

問題 No.1396 Giri
ユーザー 夕叢霧香(ゆうむらきりか)夕叢霧香(ゆうむらきりか)
提出日時 2021-02-11 16:31:52
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 27 ms / 2,000 ms
コード長 599 bytes
コンパイル時間 522 ms
コンパイル使用メモリ 68,892 KB
実行使用メモリ 9,504 KB
最終ジャッジ日時 2023-09-25 06:07:01
合計ジャッジ時間 2,728 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 24 ms
9,200 KB
testcase_01 AC 24 ms
9,260 KB
testcase_02 AC 26 ms
9,200 KB
testcase_03 AC 25 ms
9,264 KB
testcase_04 AC 25 ms
9,184 KB
testcase_05 AC 27 ms
9,204 KB
testcase_06 AC 25 ms
9,184 KB
testcase_07 AC 24 ms
9,224 KB
testcase_08 AC 24 ms
9,220 KB
testcase_09 AC 24 ms
9,200 KB
testcase_10 AC 24 ms
9,240 KB
testcase_11 AC 25 ms
9,208 KB
testcase_12 AC 24 ms
9,200 KB
testcase_13 AC 24 ms
9,204 KB
testcase_14 AC 24 ms
9,228 KB
testcase_15 AC 24 ms
9,376 KB
testcase_16 AC 24 ms
9,216 KB
testcase_17 AC 24 ms
9,204 KB
testcase_18 AC 24 ms
9,272 KB
testcase_19 AC 26 ms
9,404 KB
testcase_20 AC 26 ms
9,212 KB
testcase_21 AC 26 ms
9,200 KB
testcase_22 AC 26 ms
9,204 KB
testcase_23 AC 26 ms
9,284 KB
testcase_24 AC 27 ms
9,204 KB
testcase_25 AC 26 ms
9,504 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
using namespace std;
typedef long long lint;
#define rep(i,n)for(int i=0;i<(int)(n);++i)

const int N=1e6+10;
bool pr[N],pp[N];
int fac[N];
void pr_init(void){
  rep(i,N)if(i>=2)pr[i]=1;
  rep(i,N){
    if(i<=1)continue;
    if(!pr[i])continue;
    fac[i]=i;
    pp[i]=1;
    for(lint j=lint(i)*i;j<N;j+=i){
      pr[j]=0;
      if(fac[j]==0)fac[j]=i,pp[j]=pp[j/i]&&fac[j/i]==i;
    }
  }
}
int main(){
  int n;cin>>n;
  pr_init();
  lint p=0;
  rep(i,n+1)if(pr[i])p=i;
  lint ans=1;
  for(lint i=1;i<=n;i++){
    if(i!=p&&pp[i])ans=ans*fac[i]%998244353;
  }
  cout<<ans<<endl;
}
0