結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 35 ms
52,280 KB
testcase_01 AC 35 ms
52,444 KB
testcase_02 AC 33 ms
52,068 KB
testcase_03 AC 34 ms
52,364 KB
testcase_04 AC 32 ms
52,200 KB
testcase_05 AC 36 ms
53,436 KB
testcase_06 AC 37 ms
52,364 KB
testcase_07 AC 37 ms
52,008 KB
testcase_08 AC 37 ms
53,872 KB
testcase_09 AC 34 ms
52,464 KB
testcase_10 AC 32 ms
53,164 KB
testcase_11 AC 33 ms
52,852 KB
testcase_12 AC 33 ms
53,940 KB
testcase_13 AC 35 ms
52,892 KB
testcase_14 AC 33 ms
53,408 KB
testcase_15 AC 34 ms
52,296 KB
testcase_16 AC 35 ms
52,524 KB
testcase_17 AC 34 ms
52,532 KB
testcase_18 AC 34 ms
53,140 KB
testcase_19 AC 33 ms
52,804 KB
testcase_20 AC 36 ms
52,436 KB
testcase_21 AC 35 ms
52,996 KB
testcase_22 AC 34 ms
52,068 KB
testcase_23 AC 35 ms
53,964 KB
testcase_24 AC 34 ms
52,616 KB
testcase_25 AC 36 ms
52,532 KB
testcase_26 AC 34 ms
53,092 KB
testcase_27 AC 34 ms
53,116 KB
testcase_28 AC 35 ms
53,876 KB
testcase_29 AC 33 ms
52,532 KB
testcase_30 AC 34 ms
52,628 KB
testcase_31 AC 35 ms
52,724 KB
testcase_32 AC 35 ms
53,312 KB
testcase_33 AC 35 ms
52,768 KB
testcase_34 AC 35 ms
52,924 KB
testcase_35 AC 35 ms
52,812 KB
testcase_36 AC 34 ms
53,340 KB
testcase_37 AC 36 ms
52,828 KB
testcase_38 AC 35 ms
52,128 KB
testcase_39 AC 36 ms
52,760 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