結果

問題 No.1396 Giri
ユーザー ocvret_ocvret_
提出日時 2021-02-15 19:00:04
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 492 ms / 2,000 ms
コード長 1,108 bytes
コンパイル時間 1,796 ms
コンパイル使用メモリ 174,124 KB
実行使用メモリ 14,900 KB
最終ジャッジ日時 2023-09-30 16:11:39
合計ジャッジ時間 6,989 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 13 ms
11,396 KB
testcase_01 AC 13 ms
11,528 KB
testcase_02 AC 482 ms
14,740 KB
testcase_03 AC 14 ms
11,584 KB
testcase_04 AC 14 ms
11,576 KB
testcase_05 AC 482 ms
14,776 KB
testcase_06 AC 14 ms
11,540 KB
testcase_07 AC 14 ms
11,396 KB
testcase_08 AC 14 ms
11,496 KB
testcase_09 AC 13 ms
11,428 KB
testcase_10 AC 15 ms
11,488 KB
testcase_11 AC 14 ms
11,580 KB
testcase_12 AC 14 ms
11,592 KB
testcase_13 AC 13 ms
11,532 KB
testcase_14 AC 13 ms
11,596 KB
testcase_15 AC 15 ms
11,396 KB
testcase_16 AC 15 ms
11,440 KB
testcase_17 AC 18 ms
11,548 KB
testcase_18 AC 43 ms
11,568 KB
testcase_19 AC 246 ms
13,296 KB
testcase_20 AC 342 ms
13,944 KB
testcase_21 AC 430 ms
14,584 KB
testcase_22 AC 479 ms
14,784 KB
testcase_23 AC 492 ms
14,900 KB
testcase_24 AC 486 ms
14,732 KB
testcase_25 AC 491 ms
14,896 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
// #include<atcoder/all>

using namespace std;
// using namespace atcoder;
using ll = long long;
using ull = unsigned long long;
using P = pair<int,int>;
#define rep(i,n) for(ll i = 0;i < (ll)n;i++)
#define ALL(x) (x).begin(),(x).end()
#define MOD 1000000007

vector<int> v(2000000,0);
vector<int> sieve(){
  v[0] = 1;v[1] = 1;
  vector<int> res;
  for(int i = 2;i <= 1000000;i++){
    if(v[i])continue;
    res.push_back(i);
    for(int j = i;j <= 1000000;j+=i)v[j] = i;
  }
  return res;
}
void lcm(map<int,int> &mp,int k){
  mp[v[k]]++;
  if(v[k] == k)return;
  lcm(mp,k/v[k]);
}
int mod = 998244353;

int main(){
  
  int n;
  cin >> n;
  vector<int> p(sieve());
  ll x = 0;
  for(auto au : p){
    if(au > n)break;
    ll k = au;
    while(k*au <= n)k *= au;
    if(k*2 > n)x = k;
  }
  ll res = 1;
  map<int,int> mp;
  for(int i = 2;i <= n;i++){
    if(i == x)continue;
    map<int,int> mpp;
    lcm(mpp,i);
    for(auto au : mpp)mp[au.first] = max(mp[au.first],au.second);
  }
  for(auto &au : mp)while(au.second--)res = res*au.first%mod;
  cout << res << "\n";


  return 0;
}
0