結果

問題 No.1465 Archaea
ユーザー rlangevin
提出日時 2023-02-05 02:06:01
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 38 ms / 2,000 ms
コード長 417 bytes
コンパイル時間 180 ms
コンパイル使用メモリ 81,836 KB
実行使用メモリ 53,688 KB
最終ジャッジ日時 2024-07-03 20:21:16
合計ジャッジ時間 2,157 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 20
権限があれば一括ダウンロードができます

ソースコード

diff #

def popcount(n):
    cnt = 0
    while n:
        cnt += n & 1
        n //= 2
    return cnt

N, K = map(int, input().split())
two = 1
for i in range(20):
    M = N - two
    cnt = i
    
    if M % 3 != 0 or M < 0:
        two *= 2
        continue
    q, r = divmod(M//3, two)
    cnt += q + popcount(r)
    # print(i, M, q, r, cnt)
    if cnt <= K:
        print("YES")
        exit()
    two *= 2    
print("NO")
0