結果
問題 | No.443 GCD of Permutation |
ユーザー | d9et |
提出日時 | 2020-04-17 23:30:33 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 565 bytes |
コンパイル時間 | 197 ms |
コンパイル使用メモリ | 82,892 KB |
実行使用メモリ | 62,392 KB |
最終ジャッジ日時 | 2024-04-14 15:40:56 |
合計ジャッジ時間 | 2,822 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | WA | - |
testcase_01 | AC | 42 ms
54,524 KB |
testcase_02 | AC | 42 ms
55,768 KB |
testcase_03 | AC | 41 ms
55,252 KB |
testcase_04 | AC | 43 ms
54,144 KB |
testcase_05 | AC | 43 ms
53,796 KB |
testcase_06 | AC | 43 ms
54,376 KB |
testcase_07 | WA | - |
testcase_08 | WA | - |
testcase_09 | AC | 43 ms
55,592 KB |
testcase_10 | AC | 43 ms
54,056 KB |
testcase_11 | WA | - |
testcase_12 | WA | - |
testcase_13 | AC | 42 ms
54,732 KB |
testcase_14 | AC | 47 ms
60,392 KB |
testcase_15 | AC | 46 ms
61,212 KB |
testcase_16 | AC | 45 ms
60,264 KB |
testcase_17 | AC | 47 ms
60,588 KB |
testcase_18 | AC | 47 ms
61,056 KB |
testcase_19 | AC | 46 ms
60,928 KB |
testcase_20 | AC | 46 ms
62,232 KB |
testcase_21 | WA | - |
testcase_22 | WA | - |
testcase_23 | WA | - |
testcase_24 | WA | - |
testcase_25 | AC | 48 ms
60,676 KB |
testcase_26 | WA | - |
testcase_27 | WA | - |
testcase_28 | AC | 47 ms
60,988 KB |
testcase_29 | WA | - |
testcase_30 | AC | 47 ms
61,888 KB |
testcase_31 | WA | - |
ソースコード
from math import gcd from collections import Counter def gcds(ls): ret = 0 for i in ls: if ret*i == 0: ret = max(ret,i) else: ret = gcd(ret,i) return ret n = input() c = Counter(n) d = list(int(i) for i in c.keys()) ans = 1 if len(d) == 1: ans = n else: if len(d) == 2 and 0 in d: ans *= max(d) elif gcds(d) != 1: b = gcds(d) if b%3: ans *= b else: ans *= b//3 dsum = 0 for i,j in c.items(): dsum += int(i)*j if dsum%9 == 0: ans *= 9 elif dsum%3 == 0: ans *= 3 print(ans)