結果

問題 No.1083 余りの余り
ユーザー tktk_snsntktk_snsn
提出日時 2020-06-19 22:45:35
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 761 bytes
コンパイル時間 276 ms
コンパイル使用メモリ 87,108 KB
実行使用メモリ 177,964 KB
最終ジャッジ日時 2023-09-16 15:00:24
合計ジャッジ時間 10,289 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 73 ms
71,244 KB
testcase_01 AC 73 ms
71,300 KB
testcase_02 AC 79 ms
76,192 KB
testcase_03 AC 75 ms
71,392 KB
testcase_04 WA -
testcase_05 AC 226 ms
110,436 KB
testcase_06 AC 73 ms
71,316 KB
testcase_07 AC 78 ms
75,992 KB
testcase_08 AC 77 ms
75,792 KB
testcase_09 AC 72 ms
71,336 KB
testcase_10 AC 78 ms
76,064 KB
testcase_11 WA -
testcase_12 AC 74 ms
71,036 KB
testcase_13 AC 74 ms
71,392 KB
testcase_14 AC 73 ms
71,248 KB
testcase_15 AC 74 ms
71,484 KB
testcase_16 AC 73 ms
71,312 KB
testcase_17 AC 73 ms
71,040 KB
testcase_18 WA -
testcase_19 AC 225 ms
110,380 KB
testcase_20 AC 81 ms
76,588 KB
testcase_21 AC 94 ms
76,304 KB
testcase_22 AC 70 ms
71,036 KB
testcase_23 AC 985 ms
177,500 KB
testcase_24 AC 997 ms
177,812 KB
testcase_25 AC 1,007 ms
177,720 KB
testcase_26 AC 992 ms
177,748 KB
testcase_27 AC 79 ms
75,744 KB
testcase_28 WA -
testcase_29 AC 74 ms
71,152 KB
testcase_30 AC 72 ms
71,236 KB
testcase_31 AC 71 ms
71,036 KB
testcase_32 AC 71 ms
71,036 KB
testcase_33 AC 994 ms
177,964 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def pop_count(T):
    T = (T & 0x55555555) + ((T >> 1) & 0x55555555)
    T = (T & 0x33333333) + ((T >> 2) & 0x33333333)
    T = (T & 0x0F0F0F0F) + ((T >> 4) & 0x0F0F0F0F)
    T = (T & 0x00FF00FF) + ((T >> 8) & 0x00FF00FF)
    T = (T & 0x0000FFFF) + ((T >> 16) & 0x0000FFFF)
    return T


def main():
    N, K = map(int, input().split())
    A = list(map(int, input().split()))

    memo = {i: set() for i in range(N)}
    for bit in range(1, 1 << N):
        memo[pop_count(bit)-1].add(bit)

    dp = [0] * (1 << N)
    dp[0] = K
    for bitlist in memo.values():
        for bit in bitlist:
            for j, a in enumerate(A):
                dp[bit] = max(dp[bit], dp[bit ^ (1 << j)] % a)
    print(dp[(1 << N) - 1])


if __name__ == "__main__":
    main()
0