結果

問題 No.1004 サイコロの実装 (2)
ユーザー stngstng
提出日時 2022-08-18 10:19:16
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,036 bytes
コンパイル時間 341 ms
コンパイル使用メモリ 82,692 KB
実行使用メモリ 80,796 KB
最終ジャッジ日時 2024-04-15 19:13:52
合計ジャッジ時間 7,121 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

from multiprocessing.spawn import old_main_modules


a,b,x0,n = map(int,input().split())
li = [-1]*7
li[x0%6] = 0
now = x0%6

prd = -1
loop = [x0%6]

for i in range(7):
    now = (a*now+b)%6
    if li[now] == -1:
        li[now] = i+1
        loop.append(i+1)
    else:
        prd = i+1-li[now]
        srt = li[now]
        #print(now,i+1)
        break
li = loop
#print(li)
if prd % 2 == 1:
    li2 = li[srt:srt+prd]+li[srt:srt+prd]
else:
    #print(srt,srt+prd,"srtprd")
    li2 = li[srt:srt+prd]

tk = [0]*2
ao = [0]*2

for i in range(len(li2)):
    if (i+srt) % 2 == 0:
        tk[li2[i]%2] += 1
    else:
        ao[li2[i]%2] += 1

lcnt = (n-srt)//len(li2)

for i in range(2):
    tk[i] *= lcnt
    ao[i] *= lcnt

for i in range(srt):
    if i % 2 == 0:
        tk[li[i]%2] += 1
    else:
        ao[li[i]%2] += 1
#print(li,li2,prd,srt)
#exit()
for i in range(srt+prd*lcnt,n):
    #print(i)
    if i % 2 == 0:
        tk[li2[(i-(srt+prd*lcnt))]%2] += 1
    else:
        ao[li2[(i-(srt+prd*lcnt))]%2] += 1

print(min(tk),min(ao))
0