結果
| 問題 | No.443 GCD of Permutation |
| コンテスト | |
| ユーザー |
d9et
|
| 提出日時 | 2020-04-17 23:26:16 |
| 言語 | PyPy3 (7.3.17) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 495 bytes |
| 記録 | |
| コンパイル時間 | 263 ms |
| コンパイル使用メモリ | 85,248 KB |
| 実行使用メモリ | 60,544 KB |
| 最終ジャッジ日時 | 2026-04-19 18:00:51 |
| 合計ジャッジ時間 | 3,515 ms |
|
ジャッジサーバーID (参考情報) |
judge3_0 / judge1_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 WA * 1 |
| other | AC * 16 WA * 12 |
ソースコード
from math import gcd
from collections import Counter
def gcds(ls):
ret = 0
for i in ls:
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 *= c[1]
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)
d9et