結果

問題 No.1529 Constant Lcm
ユーザー kotatsugamekotatsugame
提出日時 2021-06-04 20:12:39
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 577 bytes
コンパイル時間 585 ms
コンパイル使用メモリ 66,816 KB
実行使用メモリ 12,416 KB
最終ジャッジ日時 2024-04-29 23:16:02
合計ジャッジ時間 2,776 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 WA -
testcase_07 AC 2 ms
5,376 KB
testcase_08 AC 2 ms
5,376 KB
testcase_09 AC 2 ms
5,376 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 AC 40 ms
7,168 KB
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 143 ms
12,160 KB
testcase_24 WA -
testcase_25 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp:9:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
    9 | main()
      | ^~~~

ソースコード

diff #

#include<iostream>
#include<atcoder/modint>
using namespace std;
using mint=atcoder::modint998244353;
int N;
bool isp[1<<20];
int vis[1<<20];
int cnt[1<<20];
main()
{
	cin>>N;
	mint ans=1;
	for(int i=2;i<N;i++)if(!isp[i])
	{
		int mx=0;
		int t=1;
		while(t<=(N-1)/i)
		{
			t*=i;
			for(int j=t;j<N;j+=i)
			{
				if(vis[j]<i)cnt[j]=0,vis[j]=i;
				cnt[j]++;
				if(mx<cnt[j])mx=cnt[j];
				if(vis[N-j]<i)cnt[N-j]=0,vis[N-j]=i;
				cnt[N-j]++;
				if(mx<cnt[N-j])mx=cnt[N-j];
			}
		}
		ans*=mint(i).pow(mx);
		for(int j=i+i;j<N;j+=i)isp[j]=true;
	}
	cout<<ans.val()<<endl;
}
0