結果

問題 No.2045 Two Reflections
ユーザー QCFium
提出日時 2022-08-19 22:15:17
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 1,015 bytes
コンパイル時間 3,093 ms
コンパイル使用メモリ 176,964 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-10-08 09:05:06
合計ジャッジ時間 2,916 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 20 WA * 7
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

int ri() {
	int n;
	scanf("%d", &n);
	return n;
}

int main() {
	int n = ri();
	
	int p = ri();
	int q = ri();
	std::vector<int> next(n);
	for (int i = 0; i < n; i++) {
		int cur_next = i;
		if (cur_next < p) cur_next = p - 1 - cur_next;
		if (cur_next >= n - q) cur_next = n - 1 - (q - 1 - (n - 1 - cur_next));
		next[i] = cur_next;
	}
	std::map<int, int> factors;
	std::vector<int> len(n, -1);
	for (int i = 0; i < n; i++) if (len[i] == -1) {
		int cur = i;
		std::vector<int> path;
		do {
			path.push_back(cur);
			cur = next[cur];
		} while (cur != i);
		for (auto i : path) len[i] = path.size();
		
		int m = path.size();
		for (int i = 2; i * i <= m; i++) {
			int cnt = 0;
			while (m % i == 0) cnt++, m /= i;
			factors[i] = std::max(factors[i], cnt);
		}
		if (m > 1) factors[m] = std::max(factors[m], 1);
	}
	int res = 2;
	for (auto i : factors) {
		for (int j = 0; j < i.second; j++) res = (int64_t) res * i.first % 998244353;
	}
	std::cout << res << std::endl;
	
	return 0;
}
0