結果
| 問題 |
No.443 GCD of Permutation
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2016-11-11 23:12:46 |
| 言語 | PyPy2 (7.3.15) |
| 結果 |
WA
(最新)
AC
(最初)
|
| 実行時間 | - |
| コード長 | 303 bytes |
| コンパイル時間 | 1,865 ms |
| コンパイル使用メモリ | 76,668 KB |
| 実行使用メモリ | 108,936 KB |
| 最終ジャッジ日時 | 2024-11-25 20:48:30 |
| 合計ジャッジ時間 | 15,225 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 26 WA * 2 |
ソースコード
import random
from fractions import gcd
N = raw_input()
if all(d==N[0] for d in N):
print N
exit()
ans = gcd(int(N), int(N[::-1]))
N = list(N)
for i in xrange(10**3):
random.shuffle(N)
ans = gcd(ans, int(''.join(map(str,N))))
if ans == 1:
print 1
exit()
print ans