結果

問題 No.1529 Constant Lcm
ユーザー inksamuraiinksamurai
提出日時 2021-06-04 23:14:26
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 2,349 bytes
コンパイル時間 1,380 ms
コンパイル使用メモリ 115,836 KB
実行使用メモリ 34,732 KB
最終ジャッジ日時 2024-04-30 11:58:45
合計ジャッジ時間 6,020 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 12 ms
34,732 KB
testcase_01 AC 14 ms
27,684 KB
testcase_02 AC 12 ms
27,620 KB
testcase_03 AC 12 ms
27,600 KB
testcase_04 AC 12 ms
27,572 KB
testcase_05 AC 12 ms
27,600 KB
testcase_06 AC 11 ms
27,504 KB
testcase_07 AC 12 ms
27,540 KB
testcase_08 AC 12 ms
27,452 KB
testcase_09 AC 11 ms
27,588 KB
testcase_10 TLE -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
権限があれば一括ダウンロードができます

ソースコード

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) (ll)(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 <ll,ll>
#define rep(i,n) for(ll i = 0 ; i < n ; i++) 
#define drep(i,n) for(ll i = n-1 ; i >= 0 ; i--)
#define crep(i,x,n) for(ll i = x ; i < n ; i++)
#define vi vector <ll> 
#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 ll max_n = 1030002;
 
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) primefact[max_n];

unordered_map<ll,ll>mp;

void merg(ll x,ll y) {

	unordered_map <ll,ll> nmp;

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

	for(auto p : nmp) {
		mp[p.fi]=max(mp[p.fi],p.se);
	}
}

int main(){
fcin;
	ll n;
	cin>>n;
	
	crep(i,1,n) {
		ll x=i,y=x;
		for(ll j=2;j<=sqrt(x);j++) {
			while(y%j==0) {
				ll 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) {
		merg(i,n-i);
	}
	
	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