結果

問題 No.443 GCD of Permutation
ユーザー square1001square1001
提出日時 2018-05-19 20:25:38
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 828 bytes
コンパイル時間 676 ms
コンパイル使用メモリ 82,316 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-10 23:48:40
合計ジャッジ時間 2,714 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <random>
#include <string>
#include <iostream>
#include <algorithm>
using namespace std;
int p[] = { 2, 3, 5, 7 };
string s;
int main() {
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	cin >> s;
	bool same = true;
	for (int i = 1; i < s.size(); i++) {
		if (i >= 1 && s[i] != s[i - 1]) same = false;
	}
	if (same) cout << s << '\n';
	else {
		int ret = 1;
		for (int i = 0; i < 4; i++) {
			int z = 1 << 30;
			for (int j = 0; j < 20; j++) {
				random_shuffle(s.begin(), s.end());
				int mod = p[i] * p[i] * p[i] * p[i] * p[i] * p[i], cur = 0;
				for (int k = 0; k < s.size(); k++) {
					cur = (cur * 10 + (s[k] - '0')) % mod;
				}
				int c = 0;
				while (c < 6 && cur % p[i] == 0) cur /= p[i], c++;
				z = min(z, c);
			}
			for (int j = 0; j < z; j++) ret *= p[i];
		}
		cout << ret << '\n';
	}
	return 0;
}
0