結果

問題 No.2045 Two Reflections
ユーザー QCFiumQCFium
提出日時 2022-08-19 22:17:38
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,118 bytes
コンパイル時間 1,773 ms
コンパイル使用メモリ 174,172 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-17 00:58:45
合計ジャッジ時間 2,812 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 7 ms
6,120 KB
testcase_03 AC 6 ms
5,376 KB
testcase_04 AC 7 ms
5,376 KB
testcase_05 AC 3 ms
5,376 KB
testcase_06 AC 4 ms
5,376 KB
testcase_07 AC 6 ms
5,376 KB
testcase_08 AC 6 ms
5,376 KB
testcase_09 AC 8 ms
5,376 KB
testcase_10 AC 7 ms
5,376 KB
testcase_11 AC 3 ms
5,376 KB
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 AC 2 ms
5,376 KB
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 11 ms
5,376 KB
testcase_21 AC 7 ms
5,376 KB
testcase_22 AC 8 ms
5,376 KB
testcase_23 AC 7 ms
5,376 KB
testcase_24 AC 6 ms
5,376 KB
testcase_25 AC 8 ms
5,376 KB
testcase_26 AC 6 ms
5,376 KB
testcase_27 AC 7 ms
5,736 KB
testcase_28 AC 6 ms
5,488 KB
testcase_29 AC 6 ms
5,668 KB
権限があれば一括ダウンロードができます

ソースコード

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(2 * n);
	for (int i = 0; i < 2 * n; i++) {
		int cur_next = i % n;
		if (i < n && cur_next < p) cur_next = p - 1 - cur_next;
		if (i >= n && cur_next >= n - q) cur_next = n - 1 - (q - 1 - (n - 1 - cur_next));
		if (i < n) cur_next += n;
		next[i] = cur_next;
	}
	std::map<int, int> factors;
	std::vector<int> len(2 * n, -1);
	for (int i = 0; i < 2 * 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();
		// std::cerr << len[i] << std::endl;
		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 = 1;
	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