結果

問題 No.1004 サイコロの実装 (2)
ユーザー wagasa2wagasa2
提出日時 2020-03-07 01:10:12
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 767 bytes
コンパイル時間 88 ms
コンパイル使用メモリ 12,928 KB
実行使用メモリ 821,248 KB
最終ジャッジ日時 2024-04-22 11:39:50
合計ジャッジ時間 3,990 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 28 ms
10,496 KB
testcase_01 AC 28 ms
10,752 KB
testcase_02 AC 26 ms
10,624 KB
testcase_03 AC 26 ms
10,752 KB
testcase_04 AC 26 ms
10,752 KB
testcase_05 AC 26 ms
10,752 KB
testcase_06 WA -
testcase_07 AC 26 ms
10,624 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 28 ms
10,496 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 MLE -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
testcase_38 -- -
testcase_39 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

def lcgs(a, b, x_0, m=2**32):
    x = x_0
    while True:
        x = (a*x + b) % m
        yield x

def f(lst):
    return [lst[0:i+1] for i in range(len(lst))]

def get_space(xs, step, n_people=2):
    return [sum(x) for x in f(xs[step::n_people])]

def num_black(lst_space):
    return sum([1 for s in lst_space if s % 2 == 1])

def num_white(lst_space):
    return sum([1 for s in lst_space if s % 2 == 0])

def cal_score(n_black, n_white):
    return min([n_black, n_white])

n = 2
a, b, x_0, N = tuple(map(int, input().split()))
g = lcgs(a, b, x_0)
xs = [next(g) for i in range(n*N)]
space = [get_space(xs, i) for i in range(n)]
score = [cal_score(num_black(lst), num_white(lst)) for lst in space]
score = [" ".join(map(str, score))]
p = list(map(print, score))
0