結果
問題 | No.1396 Giri |
ユーザー | ぷら |
提出日時 | 2021-02-14 21:34:21 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 12 ms / 2,000 ms |
コード長 | 1,471 bytes |
コンパイル時間 | 1,209 ms |
コンパイル使用メモリ | 167,432 KB |
実行使用メモリ | 4,384 KB |
最終ジャッジ日時 | 2023-09-29 14:44:23 |
合計ジャッジ時間 | 2,280 ms |
ジャッジサーバーID (参考情報) |
judge11 / judge14 |
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 3 ms
4,380 KB |
testcase_01 | AC | 3 ms
4,376 KB |
testcase_02 | AC | 12 ms
4,380 KB |
testcase_03 | AC | 2 ms
4,376 KB |
testcase_04 | AC | 3 ms
4,376 KB |
testcase_05 | AC | 12 ms
4,376 KB |
testcase_06 | AC | 3 ms
4,376 KB |
testcase_07 | AC | 3 ms
4,380 KB |
testcase_08 | AC | 3 ms
4,384 KB |
testcase_09 | AC | 3 ms
4,376 KB |
testcase_10 | AC | 3 ms
4,376 KB |
testcase_11 | AC | 3 ms
4,376 KB |
testcase_12 | AC | 3 ms
4,380 KB |
testcase_13 | AC | 3 ms
4,380 KB |
testcase_14 | AC | 4 ms
4,376 KB |
testcase_15 | AC | 4 ms
4,380 KB |
testcase_16 | AC | 5 ms
4,376 KB |
testcase_17 | AC | 5 ms
4,376 KB |
testcase_18 | AC | 5 ms
4,376 KB |
testcase_19 | AC | 8 ms
4,376 KB |
testcase_20 | AC | 9 ms
4,376 KB |
testcase_21 | AC | 10 ms
4,380 KB |
testcase_22 | AC | 10 ms
4,376 KB |
testcase_23 | AC | 10 ms
4,376 KB |
testcase_24 | AC | 10 ms
4,376 KB |
testcase_25 | AC | 10 ms
4,376 KB |
ソースコード
#include <bits/stdc++.h> #define rep(i,n) for(int i = 0; i < int(n); i++) #define rrep(i,n) for(int i = int(n)-1; i >= 0; i--) #define all(a) a.begin(),a.end() #define rall(a) a.rbegin(),a.rend() #define pb push_back using namespace std; using ll = long long; using Pi = pair<int,int>; using Pll = pair<ll,ll>; template<class T> bool chmax(T &a, const T &b) {if(a < b) {a = b; return true;} return false;} template<class T> bool chmin(T &a, const T &b) {if(b < a) {a = b; return true;} return false;} int dx[] = {1, 0,-1, 0, 1, 1,-1,-1}; int dy[] = {0, 1, 0,-1, 1,-1, 1,-1}; ll mod = 998244353; ll MOD = 1000000007; int inf = 1001001001; ll INF = 1001001001001001001; ll mod_pow(ll x,ll y,ll m) { ll res = 1; while(y > 0) { if(y%2) { res = res*x%m; } x = x*x%m; y /= 2; } return res; } int main() { int N; cin >> N; vector<bool>prime(1000005,1); prime[1] = 0; for(int i = 2; i <= N; i++) { if(!prime[i]) { continue; } for(int j = 2; i*j <= 1000000; j++) { prime[i*j] = 0; } } ll ans = 1; ll mx = 0; for(ll i = 1; i <= N; i++) { if(prime[i] == 1) { chmax(mx,i); ll tmp = i; while (tmp*i <= N) { tmp *= i; } tmp %= mod; ans *= tmp; ans %= mod; } } cout << ans*mod_pow(mx,mod-2,mod)%mod << endl; }