結果

問題 No.1396 Giri
ユーザー DaYuanChiDaYuanChi
提出日時 2021-03-27 01:15:47
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 703 bytes
コンパイル時間 4,576 ms
コンパイル使用メモリ 197,628 KB
実行使用メモリ 8,520 KB
最終ジャッジ日時 2023-08-19 11:58:02
合計ジャッジ時間 6,115 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 33 ms
8,164 KB
testcase_01 AC 34 ms
8,296 KB
testcase_02 WA -
testcase_03 AC 34 ms
8,208 KB
testcase_04 AC 33 ms
8,224 KB
testcase_05 WA -
testcase_06 AC 33 ms
8,392 KB
testcase_07 AC 34 ms
8,308 KB
testcase_08 AC 32 ms
8,268 KB
testcase_09 AC 33 ms
8,204 KB
testcase_10 AC 32 ms
8,224 KB
testcase_11 AC 32 ms
8,200 KB
testcase_12 AC 32 ms
8,520 KB
testcase_13 AC 33 ms
8,184 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll = long long;

const int N = 1e6;
const ll MOD = 998244353;
bool is_prime[N+5];
int d[N+5]; //d[i]=iの最小の素因数

int main(){
  for(int i = 0; i < N; i++) is_prime[i]=true; //エラトステネス
  for(int i = 2; i < N; i++){
    if(is_prime[i]) d[i] = i;
    for(int j = i + i; j < N; j += i){
      is_prime[j] = false;
      if(is_prime[i] && d[j]==0) d[j] = i;
    }
  }
  int n; cin >> n;
  int flag = 0;
  for(int i = n; i >= 2; i--){
    if(is_prime[i]){
      flag = i;
      break;
    }
  }
  ll ans = 1;
  for(int i = 1; i <= n; i++){
    if(i!=flag) ans = ans*i/gcd(ans, i)%MOD;
  }
  cout << ans << endl;
  return 0;
}
    
  
0