結果

問題 No.1396 Giri
ユーザー どららどらら
提出日時 2021-02-14 22:31:17
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 222 ms / 2,000 ms
コード長 691 bytes
コンパイル時間 1,521 ms
コンパイル使用メモリ 165,200 KB
実行使用メモリ 11,440 KB
最終ジャッジ日時 2023-09-29 16:13:30
合計ジャッジ時間 8,292 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 196 ms
11,136 KB
testcase_01 AC 205 ms
11,208 KB
testcase_02 AC 205 ms
11,160 KB
testcase_03 AC 198 ms
11,200 KB
testcase_04 AC 201 ms
11,192 KB
testcase_05 AC 204 ms
11,204 KB
testcase_06 AC 202 ms
11,304 KB
testcase_07 AC 199 ms
11,188 KB
testcase_08 AC 206 ms
11,148 KB
testcase_09 AC 205 ms
11,136 KB
testcase_10 AC 204 ms
11,152 KB
testcase_11 AC 196 ms
11,136 KB
testcase_12 AC 196 ms
11,128 KB
testcase_13 AC 199 ms
11,200 KB
testcase_14 AC 198 ms
11,140 KB
testcase_15 AC 196 ms
11,140 KB
testcase_16 AC 201 ms
11,240 KB
testcase_17 AC 197 ms
11,156 KB
testcase_18 AC 193 ms
11,172 KB
testcase_19 AC 194 ms
11,188 KB
testcase_20 AC 199 ms
11,140 KB
testcase_21 AC 205 ms
11,284 KB
testcase_22 AC 222 ms
11,440 KB
testcase_23 AC 213 ms
11,212 KB
testcase_24 AC 208 ms
11,180 KB
testcase_25 AC 212 ms
11,212 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;

#define MOD 998244353

ll dp[1000005];

int main(){
  int N;
  cin >> N;

  rep(i,1000005) dp[i] = i;
  REP(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;
  REP(i,1,N+1){
    ret *= dp[i];
    ret %= MOD;
  }

  cout << ret << endl;
  
  return 0;
}

0