結果

問題 No.2190 平方数の下12桁
ユーザー lam6er
提出日時 2025-03-20 21:03:18
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 40 ms / 2,000 ms
コード長 789 bytes
コンパイル時間 168 ms
コンパイル使用メモリ 82,320 KB
実行使用メモリ 53,860 KB
最終ジャッジ日時 2025-03-20 21:03:34
合計ジャッジ時間 3,144 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 41
権限があれば一括ダウンロードができます

ソースコード

diff #

def count_factor(n, p):
    count = 0
    while n % p == 0 and n != 0:
        count += 1
        n = n // p
    return count

S = input().strip()
s = int(S)

# Check modulo 2^12
mod_2_12 = 2 ** 12
s_mod2 = s % mod_2_12
possible2 = False

if s_mod2 == 0:
    possible2 = True
else:
    k = count_factor(s_mod2, 2)
    if k % 2 == 0:
        m = s_mod2 // (2 ** k)
        if m % 8 == 1 and k < 12:
            possible2 = True

# Check modulo 5^12
mod_5_12 = 5 ** 12
s_mod5 = s % mod_5_12
possible5 = False

if s_mod5 == 0:
    possible5 = True
else:
    k = count_factor(s_mod5, 5)
    if k % 2 == 0:
        if k <= 11:
            m = s_mod5 // (5 ** k)
            if m % 5 in {1, 4}:
                possible5 = True

if possible2 and possible5:
    print("YES")
else:
    print("NO")
0