結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 135 ms
54,072 KB
testcase_01 AC 146 ms
54,140 KB
testcase_02 AC 163 ms
54,296 KB
testcase_03 AC 223 ms
57,060 KB
testcase_04 AC 255 ms
46,052 KB
testcase_05 AC 267 ms
45,936 KB
testcase_06 AC 257 ms
46,092 KB
testcase_07 AC 259 ms
46,356 KB
testcase_08 AC 261 ms
45,704 KB
testcase_09 AC 269 ms
45,996 KB
testcase_10 AC 268 ms
45,880 KB
testcase_11 AC 249 ms
46,212 KB
testcase_12 AC 265 ms
45,896 KB
testcase_13 AC 264 ms
46,064 KB
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 += (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);
   }
}
0