結果

問題 No.1083 余りの余り
ユーザー tktk_snsntktk_snsn
提出日時 2020-06-19 22:47:12
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 774 bytes
コンパイル時間 387 ms
コンパイル使用メモリ 87,212 KB
実行使用メモリ 178,356 KB
最終ジャッジ日時 2023-09-16 15:02:16
合計ジャッジ時間 10,384 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 69 ms
71,540 KB
testcase_01 AC 73 ms
71,148 KB
testcase_02 AC 79 ms
75,904 KB
testcase_03 AC 71 ms
71,408 KB
testcase_04 WA -
testcase_05 AC 225 ms
110,460 KB
testcase_06 AC 71 ms
71,080 KB
testcase_07 AC 80 ms
76,460 KB
testcase_08 AC 79 ms
75,996 KB
testcase_09 AC 72 ms
71,516 KB
testcase_10 AC 79 ms
76,000 KB
testcase_11 WA -
testcase_12 AC 71 ms
71,332 KB
testcase_13 AC 72 ms
71,408 KB
testcase_14 AC 72 ms
71,292 KB
testcase_15 AC 71 ms
71,244 KB
testcase_16 AC 71 ms
71,396 KB
testcase_17 AC 72 ms
71,544 KB
testcase_18 WA -
testcase_19 AC 225 ms
110,304 KB
testcase_20 AC 83 ms
76,300 KB
testcase_21 AC 94 ms
76,248 KB
testcase_22 AC 71 ms
71,424 KB
testcase_23 AC 1,001 ms
177,796 KB
testcase_24 AC 1,002 ms
177,924 KB
testcase_25 AC 994 ms
177,920 KB
testcase_26 AC 983 ms
177,692 KB
testcase_27 AC 76 ms
76,200 KB
testcase_28 WA -
testcase_29 AC 70 ms
71,408 KB
testcase_30 AC 71 ms
71,408 KB
testcase_31 AC 72 ms
71,332 KB
testcase_32 AC 71 ms
71,156 KB
testcase_33 AC 984 ms
177,740 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()))
    A.sort()

    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