結果

問題 No.1450 nahco314's First Problem
ユーザー ygd.ygd.
提出日時 2021-03-31 15:34:28
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 800 bytes
コンパイル時間 318 ms
コンパイル使用メモリ 82,500 KB
実行使用メモリ 54,172 KB
最終ジャッジ日時 2024-04-26 01:59:35
合計ジャッジ時間 3,407 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 37 ms
52,444 KB
testcase_01 AC 36 ms
53,220 KB
testcase_02 AC 37 ms
53,096 KB
testcase_03 WA -
testcase_04 AC 37 ms
52,212 KB
testcase_05 AC 37 ms
52,900 KB
testcase_06 AC 36 ms
53,360 KB
testcase_07 AC 37 ms
52,748 KB
testcase_08 AC 37 ms
52,792 KB
testcase_09 AC 37 ms
52,596 KB
testcase_10 AC 37 ms
52,872 KB
testcase_11 AC 37 ms
52,320 KB
testcase_12 AC 38 ms
52,456 KB
testcase_13 AC 37 ms
52,976 KB
testcase_14 AC 36 ms
53,048 KB
testcase_15 AC 38 ms
52,896 KB
testcase_16 AC 38 ms
52,932 KB
testcase_17 AC 37 ms
52,592 KB
testcase_18 AC 38 ms
53,460 KB
testcase_19 AC 37 ms
53,628 KB
testcase_20 AC 38 ms
52,360 KB
testcase_21 AC 37 ms
53,024 KB
testcase_22 AC 38 ms
52,444 KB
testcase_23 AC 39 ms
52,792 KB
testcase_24 AC 37 ms
52,868 KB
testcase_25 AC 37 ms
54,172 KB
testcase_26 AC 38 ms
52,332 KB
testcase_27 AC 37 ms
52,328 KB
testcase_28 AC 37 ms
52,008 KB
testcase_29 AC 36 ms
52,204 KB
testcase_30 AC 37 ms
53,196 KB
testcase_31 AC 37 ms
53,108 KB
testcase_32 AC 37 ms
52,532 KB
testcase_33 AC 36 ms
52,464 KB
testcase_34 AC 36 ms
53,208 KB
testcase_35 AC 36 ms
53,160 KB
testcase_36 AC 36 ms
53,700 KB
testcase_37 AC 37 ms
53,760 KB
testcase_38 AC 37 ms
53,356 KB
testcase_39 AC 38 ms
53,084 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
    popn = popcount(N)
    if popn == M:
        print(N)
        break
else:
    print(-1)
0