結果

問題 No.1396 Giri
ユーザー yamakeyamake
提出日時 2021-02-14 21:45:14
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 18 ms / 2,000 ms
コード長 1,121 bytes
コンパイル時間 1,421 ms
コンパイル使用メモリ 166,220 KB
実行使用メモリ 14,776 KB
最終ジャッジ日時 2023-09-29 15:03:25
合計ジャッジ時間 2,629 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 18 ms
14,728 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 17 ms
14,632 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 1 ms
4,376 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 1 ms
4,376 KB
testcase_11 AC 1 ms
4,384 KB
testcase_12 AC 1 ms
4,376 KB
testcase_13 AC 1 ms
4,380 KB
testcase_14 AC 1 ms
4,376 KB
testcase_15 AC 1 ms
4,376 KB
testcase_16 AC 1 ms
4,376 KB
testcase_17 AC 2 ms
4,376 KB
testcase_18 AC 3 ms
4,380 KB
testcase_19 AC 11 ms
9,028 KB
testcase_20 AC 13 ms
11,596 KB
testcase_21 AC 15 ms
13,480 KB
testcase_22 AC 16 ms
14,668 KB
testcase_23 AC 17 ms
14,712 KB
testcase_24 AC 16 ms
14,628 KB
testcase_25 AC 17 ms
14,776 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define debug(output) cout<<#output<<"= "<<output<<endl
using lint = long long;
typedef pair<int,int> P;
const lint linf=1e18+7;
const lint inf=1e9+7;
const int MOD=998244353;
long long myPow(long long x,long long n,long long rest){
    long long res=1;
    long long cur=x;
    while(n>0){
        if(n&1){
            res*=cur;
            res%=rest;
        }
        n/=2;cur*=cur;
        cur%=rest;
    }
    return res;
}
signed main(){
  int n;cin>>n;
  vector<int> memo(n+5,0);
  auto cnt=memo;
  vector<int> primes(n+5,0);
  for(int i=2;i<=n;++i){
    if(memo[i]==0){
      primes[i]=1;
      for(int j=1;j*i<=n;++j){
        memo[i*j]=1;
      }
    }
  }
  for(int i=n;i>1;--i){
    if(primes[i]){
      primes[i]=0;
      break;
    }
  }
  lint res=1;
  rep1(i,n){
    if(primes[i]>0){
      int m=0;
      lint cur=1;
      rep1(j,n){
        cur*=i;
        if(cur>n)break;
        ++m;
      }
      res*=myPow(i,m,MOD);
      res%=MOD;
    }
  }
  cout<<res<<"\n";
  return 0;
}
0