結果

問題 No.1465 Archaea
コンテスト
ユーザー rlangevin
提出日時 2023-02-05 02:06:01
言語 PyPy3
(7.3.17)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
AC  
実行時間 26 ms / 2,000 ms
コード長 417 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 120 ms
コンパイル使用メモリ 85,632 KB
実行使用メモリ 52,224 KB
最終ジャッジ日時 2026-03-25 03:55:32
合計ジャッジ時間 1,626 ms
ジャッジサーバーID
(参考情報)
judge2_1 / judge1_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 20
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

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