結果
問題 |
No.1004 サイコロの実装 (2)
|
ユーザー |
![]() |
提出日時 | 2025-06-12 19:07:02 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,413 bytes |
コンパイル時間 | 266 ms |
コンパイル使用メモリ | 82,816 KB |
実行使用メモリ | 61,824 KB |
最終ジャッジ日時 | 2025-06-12 19:07:13 |
合計ジャッジ時間 | 5,443 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 12 WA * 12 TLE * 1 -- * 13 |
ソースコード
def main(): import sys a, b, x0, N = map(int, sys.stdin.readline().split()) mod6 = 6 # Generate the cycle for x_i mod 6 current = x0 % mod6 cycle = [current] prev_states = {current: 0} start = None while True: current = (a * current + b) % mod6 if current in prev_states: start = prev_states[current] break else: prev_states[current] = len(cycle) cycle.append(current) # Extract the cyclic part cyclic_part = cycle[start:] T = len(cyclic_part) # Simulate the dice rolls and players' moves takahashi_pos = 0 takahashi_black = 0 takahashi_white = 0 aoki_pos = 0 aoki_black = 0 aoki_white = 0 total_rolls = 2 * N for i in range(1, total_rolls + 1): idx = (i - 1) % T current_mod6 = cyclic_part[idx] % mod6 d = current_mod6 + 1 if i % 2 == 1: takahashi_pos += d if takahashi_pos % 2 == 1: takahashi_black += 1 else: takahashi_white += 1 else: aoki_pos += d if aoki_pos % 2 == 1: aoki_black += 1 else: aoki_white += 1 score_t = min(takahashi_black, takahashi_white) score_a = min(aoki_black, aoki_white) print(score_t, score_a) if __name__ == "__main__": main()