結果

問題 No.1396 Giri
ユーザー qingmuyusiqingmuyusi
提出日時 2021-02-14 23:10:45
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 321 ms / 2,000 ms
コード長 2,839 bytes
コンパイル時間 3,143 ms
コンパイル使用メモリ 164,092 KB
実行使用メモリ 11,404 KB
最終ジャッジ日時 2023-09-29 17:02:41
合計ジャッジ時間 11,627 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 270 ms
11,388 KB
testcase_01 AC 254 ms
11,404 KB
testcase_02 AC 291 ms
11,084 KB
testcase_03 AC 254 ms
11,116 KB
testcase_04 AC 246 ms
11,196 KB
testcase_05 AC 266 ms
11,276 KB
testcase_06 AC 254 ms
11,104 KB
testcase_07 AC 265 ms
11,216 KB
testcase_08 AC 275 ms
11,212 KB
testcase_09 AC 273 ms
11,168 KB
testcase_10 AC 288 ms
11,116 KB
testcase_11 AC 282 ms
11,100 KB
testcase_12 AC 284 ms
11,124 KB
testcase_13 AC 279 ms
11,088 KB
testcase_14 AC 313 ms
11,100 KB
testcase_15 AC 278 ms
11,144 KB
testcase_16 AC 287 ms
11,100 KB
testcase_17 AC 303 ms
11,100 KB
testcase_18 AC 261 ms
11,088 KB
testcase_19 AC 245 ms
11,124 KB
testcase_20 AC 300 ms
11,100 KB
testcase_21 AC 299 ms
11,292 KB
testcase_22 AC 321 ms
11,180 KB
testcase_23 AC 305 ms
11,168 KB
testcase_24 AC 280 ms
11,088 KB
testcase_25 AC 294 ms
11,120 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
// #include<atcoder/all>
// using namespace atcoder;
#define rep(i,n) for(int i=0;i<n;i++)
#define FOR(i,start,end) for(int i=start;i<=end;i++)
const int INF = 1001001001;
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
typedef long long ll;
const ll MOD=998244353;
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T>auto MAX(const T& a) { return *max_element(a.begin(),a.end()); }
template<class T>auto MIN(const T& a) { return *min_element(a.begin(),a.end()); }
template<class T, class U>U SUM(const T& a, const U& v) { return accumulate(a.begin(),a.end(), v); }
template<class T, class U>U COUNT(const T& a, const U& v) { return count(a.begin(),a.end(), v); }
template<class T, class U>int LOWER(const T& a, const U& v) { return lower_bound(a.begin(),a.end(), v) - a.begin(); }
template<class T, class U>int UPPER(const T& a, const U& v) { return upper_bound(a.begin(),a.end(), v) - a.begin(); }
int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
int LCM(int a, int b) { int g = GCD(a, b); return a / g * b; }
typedef long double ld;
typedef unsigned long long int ull;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int, int>> vpii;
typedef vector<pair<ll, ll>> vpll;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<vc> vvc;
typedef vector<vs> vvs;
typedef vector<vll> vvll;
typedef map<int, int> mii;
typedef set<int> si;
//---------------------------------------------------------------------------------------------------
ll prime_factorize(ll n) {
    ll res = 1;
    for (ll p = 2;p*p <= n;++p) {
        if (n%p!=0) continue;
        ll num = 0;
        while(n%p ==0) {
            ++num;
            n/=p;
        }
        res+= num;
    }
    if (n!=1) res++;
    return res;
}
bool isPrime(int x){
    int i;
    if(x < 2)return 0;
    else if(x == 2) return 1;
    if(x%2 == 0) return 0;
    for(i = 3; i*i <= x; i += 2) if(x%i == 0) return 0;
    return 1;
}

ll dp[1000005];

int main(void){
    // Your code here!
    int n; cin >> n;
    rep(i,1000005) dp[i] = i;
    // 同じ約数の被りを消す
    FOR(i,2,1000005) {
        for (int j = i*2; j < 1000005; j += i) {
            dp[j]/= dp[i];
        }
    }

    for (int i = n; i>= 0;i--) {
        if (dp[i] == i) {
            dp[i] = 1;
            break;
        }
    }

    ll ret = 1;
    FOR(i,1,n) {
        ret *= dp[i];
        ret %= MOD;
    }
    cout << ret << endl;
}
0