結果

問題 No.1004 サイコロの実装 (2)
ユーザー lam6er
提出日時 2025-03-31 17:31:45
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 838 bytes
コンパイル時間 180 ms
コンパイル使用メモリ 82,188 KB
実行使用メモリ 83,280 KB
最終ジャッジ日時 2025-03-31 17:33:00
合計ジャッジ時間 5,361 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 24 TLE * 1 -- * 13
権限があれば一括ダウンロードができます

ソースコード

diff #

a, b, x0, N = map(int, input().split())

t_parity = 0  # Initial position is 0 (even)
a_parity = 0
t_black = t_white = 0
a_black = a_white = 0
x_current = x0

total_rolls = 2 * N

for _ in range(total_rolls):
    x_next = (a * x_current + b) & 0xFFFFFFFF
    dice = (x_next % 6) + 1
    dice_parity = dice % 2
    
    if _ % 2 == 0:
        # Takahashi's turn
        new_parity = t_parity ^ dice_parity
        if new_parity:
            t_black += 1
        else:
            t_white += 1
        t_parity = new_parity
    else:
        # Aoki's turn
        new_parity = a_parity ^ dice_parity
        if new_parity:
            a_black += 1
        else:
            a_white += 1
        a_parity = new_parity
    
    x_current = x_next

tak_score = min(t_black, t_white)
ao_score = min(a_black, a_white)

print(tak_score, ao_score)
0