結果

問題 No.1803 Remainder of Sum
ユーザー simansiman
提出日時 2022-11-21 16:07:53
言語 Ruby
(3.3.0)
結果
WA  
実行時間 -
コード長 328 bytes
コンパイル時間 511 ms
コンパイル使用メモリ 11,956 KB
実行使用メモリ 16,716 KB
最終ジャッジ日時 2023-10-22 06:53:37
合計ジャッジ時間 7,167 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 86 ms
16,120 KB
testcase_01 AC 325 ms
16,292 KB
testcase_02 AC 320 ms
16,292 KB
testcase_03 AC 321 ms
16,292 KB
testcase_04 AC 323 ms
16,292 KB
testcase_05 AC 326 ms
16,292 KB
testcase_06 WA -
testcase_07 AC 308 ms
16,232 KB
testcase_08 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

T = gets.to_i

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

  if n < m
    if 2 * n - 1 < m
      pp 'C'
      puts (n - 1) * (3 + n + 1) / 2
    else
      r = m - n
      l = n - r
      puts (r - 1) * (3 + r + 1) / 2 + l / 2
    end
  else
    if m.even?
      puts (m - 1) / 2 + 1
    else
      puts m / 2
    end
  end
end
0