結果

問題 No.2045 Two Reflections
ユーザー 沙耶花沙耶花
提出日時 2022-08-19 22:06:35
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 109 ms / 2,000 ms
コード長 1,003 bytes
コンパイル時間 4,969 ms
コンパイル使用メモリ 263,244 KB
実行使用メモリ 10,240 KB
最終ジャッジ日時 2024-04-17 00:48:04
合計ジャッジ時間 6,089 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,248 KB
testcase_02 AC 8 ms
7,552 KB
testcase_03 AC 34 ms
6,784 KB
testcase_04 AC 28 ms
7,040 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 2 ms
5,376 KB
testcase_07 AC 27 ms
6,912 KB
testcase_08 AC 11 ms
7,168 KB
testcase_09 AC 2 ms
5,376 KB
testcase_10 AC 2 ms
5,376 KB
testcase_11 AC 5 ms
5,376 KB
testcase_12 AC 2 ms
5,376 KB
testcase_13 AC 2 ms
5,376 KB
testcase_14 AC 2 ms
5,376 KB
testcase_15 AC 2 ms
5,376 KB
testcase_16 AC 2 ms
5,376 KB
testcase_17 AC 2 ms
5,376 KB
testcase_18 AC 2 ms
5,376 KB
testcase_19 AC 2 ms
5,376 KB
testcase_20 AC 109 ms
10,240 KB
testcase_21 AC 8 ms
7,552 KB
testcase_22 AC 8 ms
7,680 KB
testcase_23 AC 8 ms
7,680 KB
testcase_24 AC 8 ms
7,680 KB
testcase_25 AC 7 ms
7,680 KB
testcase_26 AC 7 ms
7,552 KB
testcase_27 AC 8 ms
7,680 KB
testcase_28 AC 8 ms
7,808 KB
testcase_29 AC 8 ms
7,680 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <stdio.h>
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace atcoder;
using mint = modint998244353;
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define Inf32 1000000001
#define Inf64 4000000000000000001


int main() {	
	
	int N,p,q;
	cin>>N>>p>>q;
	int n = N;
	mint ans = 0;
	if(p==1&&q==1)ans = 1;
	else if(p==1)ans = 2;
	else if(q==1)ans = 2;
	else if(p+q<=N)ans = 4;
	else{
		vector<int> x(n);
		rep(i,n)x[i] = i;
		reverse(x.begin(),x.begin()+p);
		reverse(x.rbegin(),x.rbegin()+q);
		
		dsu D(n);
		rep(i,n)D.merge(i,x[i]);
		mint cur = 1;
		auto g = D.groups();
		map<int,int> mp;
		rep(i,g.size()){
			int nn = g[i].size();
			for(int j=2;j*j<=n;j++){
				if(nn%j==0){
					int cnt = 0;
					while(nn%j==0){
						nn /= j;
						cnt++;
					}
					mp[j] = max(mp[j],cnt);
				}
			}
			if(nn!=1)mp[nn] = max(mp[nn],1);
			
		}
		for(auto a:mp){
			cur *= mint(a.first).pow(a.second);
		}
		ans= cur*2;
		
	}
	cout<<ans.val()<<endl;
	
    return 0;
}
0