結果

問題 No.1529 Constant Lcm
ユーザー inksamuraiinksamurai
提出日時 2021-06-04 23:07:38
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
RE  
実行時間 -
コード長 2,367 bytes
コンパイル時間 1,455 ms
コンパイル使用メモリ 122,620 KB
実行使用メモリ 16,584 KB
最終ジャッジ日時 2024-04-30 11:42:23
合計ジャッジ時間 10,958 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 5 ms
8,260 KB
testcase_01 AC 7 ms
8,512 KB
testcase_02 AC 4 ms
8,260 KB
testcase_03 AC 4 ms
8,260 KB
testcase_04 AC 4 ms
8,132 KB
testcase_05 AC 4 ms
8,256 KB
testcase_06 AC 5 ms
8,132 KB
testcase_07 AC 4 ms
8,260 KB
testcase_08 AC 4 ms
8,136 KB
testcase_09 AC 4 ms
8,132 KB
testcase_10 RE -
testcase_11 RE -
testcase_12 AC 35 ms
10,276 KB
testcase_13 RE -
testcase_14 RE -
testcase_15 RE -
testcase_16 RE -
testcase_17 RE -
testcase_18 RE -
testcase_19 RE -
testcase_20 RE -
testcase_21 RE -
testcase_22 RE -
testcase_23 RE -
testcase_24 RE -
testcase_25 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cmath>
#include <deque>
#include <algorithm>
#include <iterator>
#include <list>
#include <tuple>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <unordered_set>
#include <stack>
#include <string>
#include <vector>
#include <fstream>
#include <iostream>
#include <functional>
#include <numeric>
#include <iomanip> 
#include <stdio.h>
//eolibraries
#define lnf 3999999999999999999
#define inf 999999999
#define PI 3.14159265359
#define endl "\n"
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define ll long long
#define all(c) (c).begin(),(c).end()
#define sz(c) (int)(c).size()
#define mkp(a,b) make_pair(a,b)
#define make_unique(a) sort(all(a)),a.erase(unique(all(a)),a.end())
#define rsz(a,n) a.resize(n)
#define pii pair <int,int>
#define rep(i,n) for(int i = 0 ; i < n ; i++) 
#define drep(i,n) for(int i = n-1 ; i >= 0 ; i--)
#define crep(i,x,n) for(int i = x ; i < n ; i++)
#define vi vector <int> 
#define vec(s) vector<s>
#define rsz(a,n) a.resize(n)
#define rszv(a,n,v) a.resize(n,v)
#define fcin ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
//eodefine
 
const int max_n = 103002;
 
using namespace std;
ll mod=998244353;
ll binpow(ll a, ll b) {  
  a %= mod; ll res = 1; 
  while (b) { if (b%2) res = res * a % mod; a = a * a % mod; b /= 2; } 
  return res % mod;
}
ll gcd(ll x , ll y){
  return y == 0 ? x : gcd(y,x%y);
}
ll prod(ll a , ll b){
  a%=mod; b%=mod;
  return ((a*b)%mod);
}

ll add(ll a , ll b){
  a%=mod; b%=mod;
  return (a+b)%mod;
}

vec(pii) a[max_n];
vec(pii) primefact[max_n];


vec(pii) merg(int x,int y) {
	vec(pii) nw;
	unordered_map<int,int>mp;

	for(auto p:primefact[x]) {
		mp[p.fi]=p.se;	
	}
	for(auto p:primefact[y]) {
		if(mp.find(p.fi)==mp.end())mp[p.fi]=p.se;
		else mp[p.fi]+=p.se;
	}

	for(auto p : mp) nw.pb({p});

	return nw;
}

int main(){
fcin;
	int n;
	cin>>n;
	
	crep(i,1,n) {
		int x=i,y=x;
		for(int j=2;j<=sqrt(x);j++) {
			while(y%j==0) {
				int cnt=0;
				while(y%j==0) {y/=j; cnt++;}
				primefact[i].pb({j,cnt});
			}
		}
		if(y!=1) primefact[i].pb({y,1});
	}

	crep(i,1,n) {
		a[i] = merg(i,n-i);
	}
	
	map<int,int>mp;
	
	ll ans=1;

	crep(i,1,n) {
		for(auto p : a[i]) {
			mp[p.fi]=max(mp[p.fi],p.se);
		}
	}

	for(auto p : mp) {
		ans = prod(ans,binpow(p.fi,p.se));
	}

	cout << ans << "\n";
/*
*/
 
    return 0;   
}
0