結果

問題 No.1004 サイコロの実装 (2)
コンテスト
ユーザー Theta
提出日時 2022-10-21 14:37:30
言語 Python3
(3.14.3 + numpy 2.4.4 + scipy 1.17.1)
コンパイル:
python3 -mpy_compile _filename_
実行:
python3 _filename_
結果
TLE  
実行時間 -
コード長 708 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 456 ms
コンパイル使用メモリ 20,700 KB
実行使用メモリ 30,464 KB
最終ジャッジ日時 2026-03-21 15:07:19
合計ジャッジ時間 46,841 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge2_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 24 TLE * 14
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code


def main():
    a, b, x0, N = map(int, input().split())
    mod = 2**32 - 1

    def linear_random(x: int) -> int:
        return (a * x + b) & mod

    takahashi = [0, 0, 0]
    aoki = [0, 0, 0]

    x = x0
    for idx in range(N):
        x = linear_random(x)
        takahashi[2] += x % 6 + 1
        match takahashi[2] % 2:
            case 0:
                takahashi[1] += 1
            case 1:
                takahashi[0] += 1

        x = linear_random(x)
        aoki[2] += x % 6 + 1
        match aoki[2] % 2:
            case 0:
                aoki[1] += 1
            case 1:
                aoki[0] += 1

    print(min(takahashi[:2]), min(aoki[:2]))


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