結果
問題 | No.443 GCD of Permutation |
ユーザー | nebukuro09 |
提出日時 | 2016-11-12 00:04:26 |
言語 | Python2 (2.7.18) |
結果 |
WA
|
実行時間 | - |
コード長 | 635 bytes |
コンパイル時間 | 585 ms |
コンパイル使用メモリ | 6,692 KB |
実行使用メモリ | 7,876 KB |
最終ジャッジ日時 | 2023-08-16 20:26:32 |
合計ジャッジ時間 | 2,956 ms |
ジャッジサーバーID (参考情報) |
judge12 / judge13 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 22 ms
7,856 KB |
testcase_01 | AC | 22 ms
7,852 KB |
testcase_02 | AC | 22 ms
7,876 KB |
testcase_03 | AC | 21 ms
7,620 KB |
testcase_04 | AC | 21 ms
7,828 KB |
testcase_05 | AC | 22 ms
7,632 KB |
testcase_06 | AC | 21 ms
7,628 KB |
testcase_07 | AC | 21 ms
7,636 KB |
testcase_08 | AC | 20 ms
7,636 KB |
testcase_09 | AC | 21 ms
7,716 KB |
testcase_10 | AC | 21 ms
7,772 KB |
testcase_11 | WA | - |
testcase_12 | AC | 21 ms
7,852 KB |
testcase_13 | AC | 21 ms
7,664 KB |
testcase_14 | AC | 22 ms
7,856 KB |
testcase_15 | AC | 21 ms
7,832 KB |
testcase_16 | AC | 23 ms
7,624 KB |
testcase_17 | AC | 23 ms
7,636 KB |
testcase_18 | AC | 29 ms
7,628 KB |
testcase_19 | AC | 22 ms
7,668 KB |
testcase_20 | AC | 27 ms
7,776 KB |
testcase_21 | AC | 23 ms
7,632 KB |
testcase_22 | WA | - |
testcase_23 | WA | - |
testcase_24 | WA | - |
testcase_25 | AC | 30 ms
7,832 KB |
testcase_26 | WA | - |
testcase_27 | WA | - |
testcase_28 | AC | 21 ms
7,620 KB |
testcase_29 | WA | - |
testcase_30 | AC | 30 ms
7,664 KB |
testcase_31 | AC | 25 ms
7,832 KB |
ソースコード
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() 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