結果

問題 No.1004 サイコロの実装 (2)
コンテスト
ユーザー tsuchinaga
提出日時 2020-10-04 23:03:41
言語 TypeScript
(6.0.2)
コンパイル:
tsc.sh -p tsconfig.json
実行:
node main.js ONLINE_JUDGE
結果
WA  
実行時間 -
コード長 642 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 4,547 ms
コンパイル使用メモリ 347,080 KB
実行使用メモリ 52,972 KB
最終ジャッジ日時 2026-06-05 04:48:04
合計ジャッジ時間 10,168 ms
ジャッジサーバーID
(参考情報)
judge1_0 / judge2_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 20 WA * 18
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

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 % 1 == 0) 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