結果
| 問題 |
No.443 GCD of Permutation
|
| コンテスト | |
| ユーザー |
d9et
|
| 提出日時 | 2020-04-17 23:30:08 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 582 bytes |
| コンパイル時間 | 320 ms |
| コンパイル使用メモリ | 82,148 KB |
| 実行使用メモリ | 62,388 KB |
| 最終ジャッジ日時 | 2024-10-03 15:32:56 |
| 合計ジャッジ時間 | 2,404 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 WA * 2 |
| other | AC * 5 WA * 23 |
ソースコード
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)
print(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)
d9et