結果

問題 No.1004 サイコロの実装 (2)
ユーザー Theta
提出日時 2022-10-21 14:37:30
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
TLE  
実行時間 -
コード長 708 bytes
コンパイル時間 233 ms
コンパイル使用メモリ 12,544 KB
実行使用メモリ 17,824 KB
最終ジャッジ日時 2024-07-01 00:29:09
合計ジャッジ時間 5,927 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 24 TLE * 1 -- * 13
権限があれば一括ダウンロードができます

ソースコード

diff #


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