結果

問題 No.443 GCD of Permutation
ユーザー lam6er
提出日時 2025-03-31 17:53:45
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 685 bytes
コンパイル時間 469 ms
コンパイル使用メモリ 82,192 KB
実行使用メモリ 63,316 KB
最終ジャッジ日時 2025-03-31 17:55:17
合計ジャッジ時間 2,964 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 19 WA * 9
権限があれば一括ダウンロードができます

ソースコード

diff #

n = input().strip()

# Case where all digits are the same
if len(set(n)) == 1:
    print(n)
else:
    sum_d = sum(int(c) for c in n)
    
    # Determine factors for 3 and 9
    factor_3 = 9 if sum_d % 9 == 0 else 3 if sum_d % 3 == 0 else 1
    
    # Check if all digits are even
    all_even = all(int(c) % 2 == 0 for c in n)
    if all_even:
        # Check if all digits are 0,4,8
        is_048 = all(c in {'0', '4', '8'} for c in n)
        factor_2 = 4 if is_048 else 2
    else:
        factor_2 = 1
    
    # Check if all digits are 0 or 5
    all_05 = all(c in {'0', '5'} for c in n)
    factor_5 = 5 if all_05 else 1
    
    g = factor_3 * factor_2 * factor_5
    print(g)
0