結果

問題 No.1258 コインゲーム
ユーザー simansiman
提出日時 2020-10-19 15:34:27
言語 Ruby
(3.3.0)
結果
AC  
実行時間 550 ms / 2,000 ms
コード長 346 bytes
コンパイル時間 102 ms
コンパイル使用メモリ 11,512 KB
実行使用メモリ 15,452 KB
最終ジャッジ日時 2023-09-28 13:15:13
合計ジャッジ時間 20,938 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 170 ms
15,352 KB
testcase_01 AC 192 ms
15,232 KB
testcase_02 AC 121 ms
15,344 KB
testcase_03 AC 441 ms
15,148 KB
testcase_04 AC 490 ms
15,188 KB
testcase_05 AC 148 ms
15,452 KB
testcase_06 AC 376 ms
15,348 KB
testcase_07 AC 113 ms
15,416 KB
testcase_08 AC 107 ms
15,224 KB
testcase_09 AC 229 ms
15,332 KB
testcase_10 AC 440 ms
15,108 KB
testcase_11 AC 479 ms
15,144 KB
testcase_12 AC 369 ms
15,356 KB
testcase_13 AC 170 ms
15,072 KB
testcase_14 AC 111 ms
15,264 KB
testcase_15 AC 432 ms
15,228 KB
testcase_16 AC 153 ms
15,208 KB
testcase_17 AC 476 ms
15,396 KB
testcase_18 AC 231 ms
15,344 KB
testcase_19 AC 220 ms
15,188 KB
testcase_20 AC 375 ms
15,268 KB
testcase_21 AC 453 ms
15,324 KB
testcase_22 AC 341 ms
15,188 KB
testcase_23 AC 272 ms
15,236 KB
testcase_24 AC 153 ms
15,276 KB
testcase_25 AC 268 ms
15,424 KB
testcase_26 AC 240 ms
15,348 KB
testcase_27 AC 443 ms
15,236 KB
testcase_28 AC 176 ms
15,204 KB
testcase_29 AC 185 ms
15,188 KB
testcase_30 AC 529 ms
15,348 KB
testcase_31 AC 194 ms
15,204 KB
testcase_32 AC 131 ms
15,188 KB
testcase_33 AC 379 ms
15,232 KB
testcase_34 AC 457 ms
15,212 KB
testcase_35 AC 211 ms
15,104 KB
testcase_36 AC 445 ms
15,224 KB
testcase_37 AC 223 ms
15,336 KB
testcase_38 AC 423 ms
15,280 KB
testcase_39 AC 177 ms
15,156 KB
testcase_40 AC 540 ms
15,304 KB
testcase_41 AC 545 ms
15,232 KB
testcase_42 AC 545 ms
15,400 KB
testcase_43 AC 546 ms
15,284 KB
testcase_44 AC 546 ms
15,208 KB
testcase_45 AC 540 ms
15,032 KB
testcase_46 AC 550 ms
15,328 KB
testcase_47 AC 544 ms
15,148 KB
testcase_48 AC 540 ms
15,332 KB
testcase_49 AC 545 ms
15,220 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

class Integer
  def mod_inverse(mod)
    pow(mod - 2, mod)
  end
end

S = gets.to_i
MOD = 10 ** 9 + 7

S.times do
  n, m, x = gets.split.map(&:to_i)

  if (n + x).even?
    puts ((m + 1).pow(n, MOD) + (m - 1).pow(n, MOD)) * 2.mod_inverse(MOD) % MOD
  else
    puts ((m + 1).pow(n, MOD) - (m - 1).pow(n, MOD)) * 2.mod_inverse(MOD) % MOD
  end
end
0