結果

問題 No.1396 Giri
ユーザー 👑 PCTprobabilityPCTprobability
提出日時 2021-02-14 22:12:22
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 18 ms / 2,000 ms
コード長 1,755 bytes
コンパイル時間 4,042 ms
コンパイル使用メモリ 260,212 KB
実行使用メモリ 10,808 KB
最終ジャッジ日時 2023-09-29 15:48:01
合計ジャッジ時間 5,330 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 17 ms
10,752 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 17 ms
10,784 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 1 ms
4,376 KB
testcase_08 AC 1 ms
4,380 KB
testcase_09 AC 1 ms
4,376 KB
testcase_10 AC 1 ms
4,380 KB
testcase_11 AC 1 ms
4,380 KB
testcase_12 AC 1 ms
4,380 KB
testcase_13 AC 1 ms
4,376 KB
testcase_14 AC 2 ms
4,380 KB
testcase_15 AC 1 ms
4,376 KB
testcase_16 AC 2 ms
4,376 KB
testcase_17 AC 2 ms
4,380 KB
testcase_18 AC 2 ms
4,376 KB
testcase_19 AC 9 ms
7,300 KB
testcase_20 AC 12 ms
8,828 KB
testcase_21 AC 15 ms
9,988 KB
testcase_22 AC 18 ms
10,808 KB
testcase_23 AC 17 ms
10,744 KB
testcase_24 AC 17 ms
10,740 KB
testcase_25 AC 17 ms
10,772 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#if __has_include(<atcoder/all>)
#include <atcoder/all>
using namespace atcoder;
#endif
using ll = long long;
using ld = long double;
#define all(s) (s).begin(),(s).end()
#define vcin(n) for(ll i=0;i<ll(n.size());i++) cin>>n[i]
#define rep2(i, m, n) for (int i = (m); i < (n); ++i)
#define rep(i, n) rep2(i, 0, n)
#define drep2(i, m, n) for (int i = (m)-1; i >= (n); --i)
#define drep(i, n) drep2(i, n, 0)
#define rever(vec) reverse(vec.begin(), vec.end())
#define sor(vec) sort(vec.begin(), vec.end())
#define fi first
#define se second
//#define P pair<ll,ll>
const ll mod = 998244353;
//const ll mod = 1000000007;
const ll inf = 2000000000000000000ll;
static const long double pi = 3.141592653589793;
void YesNo(bool a){if(a){cout<<"Yes"<<endl;}else{cout<<"No"<<endl;}}
void YESNO(bool a){if(a){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}}
template<class T,class U> void chmax(T& t,const U& u){if(t<u) t=u;}
template<class T,class U> void chmin(T& t,const U& u){if(t>u) t=u;}
ll modPow(ll a, ll n, ll mod) { ll ret = 1; ll p = a % mod; while (n) { if (n & 1) ret = ret * p % mod; p = p * p % mod; n >>= 1; } return ret; }

int main() {
  /* mod は 1e9+7 */
  ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
  cout<< fixed << setprecision(10);
  ll a;
  cin>>a;
  vector<ll> n(a+2,1);
  n[0]=n[1]=0;
  for(int i=2;i<=a;i++){
    if(n[i]){
      for(int j=i*2;j<=a;j+=i){
        n[j]=0;
      }
    }
  }
  ll t=0;
  for(int i=a;i>=1;i--){
    if(n[i]){
      t=i;
      break;
    }
  }
  ll ans=1;
  for(int i=1;i<=a;i++){
    if(n[i]==0||i==t) continue;
    ll tmp=1;
    ll k=i;
    while(k*i<=a){
      tmp++;
      k*=i;
    }
    ans*=modPow(i,tmp,mod);
    ans%=mod;
  }
  cout<<ans<<endl;
}
0