結果

問題 No.1252 数字根D
ユーザー yuruhiyayuruhiya
提出日時 2020-10-10 18:21:32
言語 Crystal
(1.11.2)
結果
AC  
実行時間 7 ms / 2,000 ms
コード長 358 bytes
コンパイル時間 19,030 ms
コンパイル使用メモリ 253,292 KB
実行使用メモリ 4,956 KB
最終ジャッジ日時 2023-09-13 12:07:41
合計ジャッジ時間 20,566 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
4,492 KB
testcase_01 AC 3 ms
4,440 KB
testcase_02 AC 3 ms
4,456 KB
testcase_03 AC 4 ms
4,772 KB
testcase_04 AC 7 ms
4,956 KB
testcase_05 AC 7 ms
4,760 KB
testcase_06 AC 7 ms
4,764 KB
testcase_07 AC 7 ms
4,928 KB
testcase_08 AC 7 ms
4,860 KB
testcase_09 AC 7 ms
4,888 KB
testcase_10 AC 7 ms
4,840 KB
testcase_11 AC 7 ms
4,880 KB
testcase_12 AC 7 ms
4,928 KB
testcase_13 AC 7 ms
4,804 KB
testcase_14 AC 3 ms
4,500 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

lib C
  fun strtoll(s : UInt8*, p : UInt8**, b : Int32) : Int64
end

class String
  def to_i64
    C.strtoll(self, nil, 10)
  end
end

def tri(x)
  x * (x + 1) // 2
end

def calc(x, d)
  x < 0 ? 0i64 : tri(d.pred) * (x // d.pred) + tri(x % d.pred)
end

read_line.to_i.times do
  d, a, b = read_line.split.map(&.to_i64)
  puts calc(b, d) - calc(a - 1, d)
end
0