結果

問題 No.443 GCD of Permutation
ユーザー d9etd9et
提出日時 2020-04-17 23:26:16
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 495 bytes
コンパイル時間 280 ms
コンパイル使用メモリ 82,408 KB
実行使用メモリ 62,376 KB
最終ジャッジ日時 2024-04-14 15:39:22
合計ジャッジ時間 2,810 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 42 ms
53,792 KB
testcase_02 WA -
testcase_03 AC 41 ms
55,076 KB
testcase_04 AC 41 ms
54,148 KB
testcase_05 AC 42 ms
54,304 KB
testcase_06 AC 41 ms
54,900 KB
testcase_07 AC 42 ms
55,280 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 41 ms
54,352 KB
testcase_11 WA -
testcase_12 AC 42 ms
55,196 KB
testcase_13 AC 42 ms
55,156 KB
testcase_14 AC 45 ms
60,424 KB
testcase_15 WA -
testcase_16 AC 46 ms
60,400 KB
testcase_17 AC 45 ms
60,144 KB
testcase_18 AC 46 ms
60,804 KB
testcase_19 AC 45 ms
60,160 KB
testcase_20 AC 46 ms
61,024 KB
testcase_21 AC 46 ms
60,272 KB
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 AC 45 ms
60,700 KB
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 AC 46 ms
60,352 KB
testcase_31 AC 46 ms
61,540 KB
権限があれば一括ダウンロードができます

ソースコード

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