結果

問題 No.1004 サイコロの実装 (2)
ユーザー tsuchinagatsuchinaga
提出日時 2020-10-04 23:05:00
言語 TypeScript
(5.7.2)
結果
WA  
実行時間 -
コード長 642 bytes
コンパイル時間 7,720 ms
コンパイル使用メモリ 229,312 KB
実行使用メモリ 41,584 KB
最終ジャッジ日時 2024-12-31 16:22:02
合計ジャッジ時間 11,388 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 22 WA * 16
権限があれば一括ダウンロードができます

ソースコード

diff #

function issue1004(input: string) {
    let inputs = input.trim().split(" ").map((a: string): number => Number(a))
    let a = inputs[0]
    let b = inputs[1]
    let x0 = inputs[2]
    let n = inputs[3]
    let m = 2 ** 32

    // 奇数と偶数が繰り返されるため、最初が奇数なら一人目が、最初が偶数なら二人目が勝つ
    let x = (a * x0 + b) % m
    let w = Math.floor(n / 2)
    if (x % 2 == 1) console.log([w, 0].join(" "))
    else console.log([0, w].join(" "))
}

let path: string = "/dev/stdin"
if (process.platform == "win32") path = "./stdin.txt"
issue1004(require('fs').readFileSync(path, 'utf8'))
0