結果
| 問題 |
No.443 GCD of Permutation
|
| コンテスト | |
| ユーザー |
👑 SPD_9X2
|
| 提出日時 | 2025-07-28 04:10:41 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,043 bytes |
| コンパイル時間 | 295 ms |
| コンパイル使用メモリ | 82,712 KB |
| 実行使用メモリ | 78,404 KB |
| 最終ジャッジ日時 | 2025-07-28 04:11:12 |
| 合計ジャッジ時間 | 29,528 ms |
|
ジャッジサーバーID (参考情報) |
judge6 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 26 WA * 2 |
ソースコード
"""
https://yukicoder.me/problems/no/443
桁が多い場合はほとんど1になりそうなんだよな
小さい場合は無作為shuffleでも効きそう
2222122
みたいなのに弱いか?
偶数対策だけしておくべきか
244444444
もまずいか
"""
import math
import random
import sys
from collections import defaultdict
# 制限を解除(無制限にしたい場合は0を指定)
sys.set_int_max_str_digits(0)
N = list(input())
dic = defaultdict(int)
for c in N:
dic[int(c)] += 1
import time
start = time.time()
ans = 0
while True:
random.shuffle(N)
X = int("".join(N))
ans = math.gcd(X,ans)
# 0.8秒経ったらループを抜ける
if time.time() - start > 0.8:
break
if len(N) > 20:
if dic[1]+dic[3]+dic[5]+dic[7]+dic[9] > 0:
while ans % 2 == 0:
ans //= 2
if dic[2] > 0 or dic[6] > 0 or dic[0] > 0:
while ans % 4 == 0:
ans //= 4
if dic[4] > 0:
while ans % 8 == 0:
ans //= 8
print (ans)
SPD_9X2