結果

問題 No.1252 数字根D
ユーザー tentententen
提出日時 2021-03-15 16:02:31
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 663 bytes
コンパイル時間 2,317 ms
コンパイル使用メモリ 74,440 KB
実行使用メモリ 57,780 KB
最終ジャッジ日時 2024-04-24 18:49:07
合計ジャッジ時間 6,884 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 131 ms
41,092 KB
testcase_01 AC 148 ms
41,600 KB
testcase_02 AC 162 ms
41,948 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

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)(a - 1) / (d - 1) * d * (d - 1) / 2;
    		int leftMod = (a - 1) % (d - 1);
    		left += leftMod * (leftMod + 1) / 2;
    		long right = (long)b / (d - 1) * d * (d - 1) / 2;
    		int rightMod = b % (d - 1);
    		right += rightMod * (rightMod + 1) / 2;
    		sb.append(right - left).append("\n");
		}
		System.out.print(sb);
   }
}
0