結果
問題 | No.1252 数字根D |
ユーザー | tenten |
提出日時 | 2021-03-15 16:29:30 |
言語 | Java21 (openjdk 21) |
結果 |
AC
|
実行時間 | 240 ms / 2,000 ms |
コード長 | 701 bytes |
コンパイル時間 | 2,140 ms |
コンパイル使用メモリ | 74,428 KB |
実行使用メモリ | 46,632 KB |
最終ジャッジ日時 | 2024-04-24 19:02:44 |
合計ジャッジ時間 | 5,735 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 115 ms
40,792 KB |
testcase_01 | AC | 129 ms
41,568 KB |
testcase_02 | AC | 150 ms
41,744 KB |
testcase_03 | AC | 197 ms
44,560 KB |
testcase_04 | AC | 229 ms
45,892 KB |
testcase_05 | AC | 240 ms
45,816 KB |
testcase_06 | AC | 231 ms
46,632 KB |
testcase_07 | AC | 228 ms
46,152 KB |
testcase_08 | AC | 240 ms
46,600 KB |
testcase_09 | AC | 230 ms
45,712 KB |
testcase_10 | AC | 225 ms
46,076 KB |
testcase_11 | AC | 226 ms
46,364 KB |
testcase_12 | AC | 232 ms
46,224 KB |
testcase_13 | AC | 220 ms
45,736 KB |
testcase_14 | AC | 121 ms
41,008 KB |
ソースコード
import java.util.*; public class Main { public static void main (String[] args) { Scanner sc = new Scanner(System.in); int t = sc.nextInt(); StringBuilder sb = new StringBuilder(); for (int i = 0; i < t; i++) { int d = sc.nextInt(); int a = sc.nextInt(); int b = sc.nextInt(); long left = (long)(Math.max(a - 1, 0)) / (d - 1) * d * (d - 1) / 2; int leftMod = (Math.max(a - 1, 0)) % (d - 1); left += (long)leftMod * (leftMod + 1) / 2; long right = (long)b / (d - 1) * d * (d - 1) / 2; int rightMod = b % (d - 1); right += (long)rightMod * (rightMod + 1) / 2; sb.append(right - left).append("\n"); } System.out.print(sb); } }