結果

問題 No.443 GCD of Permutation
ユーザー gew1fw
提出日時 2025-06-12 16:35:50
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 628 bytes
コンパイル時間 335 ms
コンパイル使用メモリ 82,304 KB
実行使用メモリ 63,104 KB
最終ジャッジ日時 2025-06-12 16:35:57
合計ジャッジ時間 2,693 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 19 WA * 9
権限があれば一括ダウンロードができます

ソースコード

diff #

n = input().strip()

# Check if all digits are the same
if len(set(n)) == 1:
    print(n)
else:
    sum_digits = sum(int(c) for c in n)
    sum_factor = 9 if sum_digits % 9 == 0 else (3 if sum_digits % 3 == 0 else 1)
    
    # Check if all digits are even
    all_even = all(int(c) % 2 == 0 for c in n)
    if all_even:
        all_048 = all(c in {'0', '4', '8'} for c in n)
        k = 2 if all_048 else 1
    else:
        k = 0
    
    # Check if all digits are 0 or 5
    all_0_or_5 = all(c in {'0', '5'} for c in n)
    m = 1 if all_0_or_5 else 0
    
    gcd_value = sum_factor * (2 ** k) * (5 ** m)
    print(gcd_value)
0