結果
| 問題 |
No.443 GCD of Permutation
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2016-11-12 00:14:28 |
| 言語 | Python2 (2.7.18) |
| 結果 |
RE
|
| 実行時間 | - |
| コード長 | 718 bytes |
| コンパイル時間 | 152 ms |
| コンパイル使用メモリ | 6,912 KB |
| 実行使用メモリ | 8,192 KB |
| 最終ジャッジ日時 | 2024-11-25 10:34:23 |
| 合計ジャッジ時間 | 1,749 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 RE * 2 |
| other | AC * 7 WA * 2 RE * 19 |
ソースコード
from itertools import combinations, permutations
from fractions import gcd
N = raw_input()
if all(d==N[0] for d in N):
print N
exit()
ans = 1
S = set(N)
if len(S) == 2 and '0' in S:
m = sorted(list(S))[1]
if N.count(m)%3 == 0:
print int(m)*3
else:
print m
exit()
if all(int(d)%3 == 0 and sum(int(d) for d in N)%27 == 0):
print 27
exit()
elif all(int(d1+d2)%4==0 and int(d2+d1)%4 == 0 for d1, d2 in combinations(S, 2)):
if all(N.count(i) < 2 or int(i+i) % 4 == 0 for i in '0123456789'):
ans *= 4
elif all(int(d)%2==0 for d in S):
ans *= 2
if sum(int(d) for d in N)%9 == 0:
ans *= 9
elif sum(int(d) for d in N)%3 == 0:
ans *= 3
print ans