結果

問題 No.1450 nahco314's First Problem
ユーザー ygd.ygd.
提出日時 2021-03-31 15:35:34
言語 PyPy3
(7.3.13)
結果
AC  
実行時間 77 ms / 2,000 ms
コード長 824 bytes
コンパイル時間 282 ms
コンパイル使用メモリ 87,108 KB
実行使用メモリ 71,636 KB
最終ジャッジ日時 2023-08-08 08:35:36
合計ジャッジ時間 5,443 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 72 ms
71,196 KB
testcase_01 AC 75 ms
71,536 KB
testcase_02 AC 75 ms
71,396 KB
testcase_03 AC 74 ms
71,540 KB
testcase_04 AC 75 ms
71,392 KB
testcase_05 AC 75 ms
71,248 KB
testcase_06 AC 75 ms
71,440 KB
testcase_07 AC 75 ms
71,636 KB
testcase_08 AC 76 ms
71,356 KB
testcase_09 AC 75 ms
71,448 KB
testcase_10 AC 75 ms
71,416 KB
testcase_11 AC 73 ms
71,628 KB
testcase_12 AC 75 ms
71,128 KB
testcase_13 AC 74 ms
71,416 KB
testcase_14 AC 74 ms
71,084 KB
testcase_15 AC 76 ms
71,612 KB
testcase_16 AC 76 ms
71,284 KB
testcase_17 AC 76 ms
71,396 KB
testcase_18 AC 76 ms
71,372 KB
testcase_19 AC 73 ms
71,364 KB
testcase_20 AC 74 ms
71,304 KB
testcase_21 AC 74 ms
71,588 KB
testcase_22 AC 74 ms
71,416 KB
testcase_23 AC 74 ms
71,632 KB
testcase_24 AC 75 ms
71,148 KB
testcase_25 AC 71 ms
71,356 KB
testcase_26 AC 74 ms
71,444 KB
testcase_27 AC 74 ms
71,484 KB
testcase_28 AC 75 ms
71,432 KB
testcase_29 AC 74 ms
71,376 KB
testcase_30 AC 74 ms
71,552 KB
testcase_31 AC 75 ms
71,300 KB
testcase_32 AC 76 ms
71,308 KB
testcase_33 AC 75 ms
71,592 KB
testcase_34 AC 77 ms
71,452 KB
testcase_35 AC 75 ms
71,444 KB
testcase_36 AC 76 ms
71,376 KB
testcase_37 AC 75 ms
71,276 KB
testcase_38 AC 76 ms
71,412 KB
testcase_39 AC 77 ms
71,484 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def popcount(x): #https://qiita.com/zawawahoge/items/8bbd4c2319e7f7746266
    '''xの立っているビット数をカウントする関数
    (xは64bit整数)'''
 
    # 2bitごとの組に分け、立っているビット数を2bitで表現する
    x = x - ((x >> 1) & 0x5555555555555555)
 
    # 4bit整数に 上位2bit + 下位2bit を計算した値を入れる
    x = (x & 0x3333333333333333) + ((x >> 2) & 0x3333333333333333)
 
    x = (x + (x >> 4)) & 0x0f0f0f0f0f0f0f0f # 8bitごと
    x = x + (x >> 8) # 16bitごと
    x = x + (x >> 16) # 32bitごと
    x = x + (x >> 32) # 64bitごと = 全部の合計
    return x & 0x0000007f

X = int(input())
MAX = 64
for M in range(MAX):
    N = X^M
    if N == 0: continue
    popn = popcount(N)
    if popn == M:
        print(N)
        break
else:
    print(-1)
0