結果

問題 No.443 GCD of Permutation
コンテスト
ユーザー nebukuro09
提出日時 2016-11-11 23:23:01
言語 PyPy2
(7.3.15)
結果
WA  
実行時間 -
コード長 518 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 169 ms
コンパイル使用メモリ 77,308 KB
最終ジャッジ日時 2025-12-03 22:40:07
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3 WA * 1
other AC * 18 WA * 10
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

from itertools import combinations

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:
    print sorted(list(S))[1]
    exit()

if 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 and 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
0