結果

問題 No.443 GCD of Permutation
ユーザー d9et
提出日時 2020-04-17 23:26:16
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 495 bytes
コンパイル時間 372 ms
コンパイル使用メモリ 82,000 KB
実行使用メモリ 61,372 KB
最終ジャッジ日時 2024-10-03 15:31:36
合計ジャッジ時間 2,742 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3 WA * 1
other AC * 16 WA * 12
権限があれば一括ダウンロードができます

ソースコード

diff #

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)
0