結果

問題 No.752 mod数列
ユーザー htensaihtensai
提出日時 2019-12-11 12:34:16
言語 Java21
(openjdk 21)
結果
TLE  
実行時間 -
コード長 1,088 bytes
コンパイル時間 1,891 ms
コンパイル使用メモリ 73,900 KB
実行使用メモリ 60,464 KB
最終ジャッジ日時 2023-09-06 13:02:50
合計ジャッジ時間 7,908 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 42 ms
54,076 KB
testcase_01 AC 42 ms
49,284 KB
testcase_02 AC 43 ms
49,792 KB
testcase_03 AC 44 ms
49,524 KB
testcase_04 AC 41 ms
49,284 KB
testcase_05 AC 42 ms
49,536 KB
testcase_06 AC 41 ms
49,376 KB
testcase_07 AC 41 ms
49,180 KB
testcase_08 AC 41 ms
49,176 KB
testcase_09 AC 41 ms
49,240 KB
testcase_10 AC 82 ms
51,988 KB
testcase_11 AC 78 ms
52,216 KB
testcase_12 AC 78 ms
52,288 KB
testcase_13 AC 75 ms
52,356 KB
testcase_14 AC 79 ms
51,924 KB
testcase_15 AC 667 ms
59,840 KB
testcase_16 TLE -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;
import java.io.*;

public class Main {
    public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] first = br.readLine().split(" ", 2);
        int p = Integer.parseInt(first[0]);
        int q = Integer.parseInt(first[1]);
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < q; i++) {
            String[] line = br.readLine().split(" ", 2);
            int left = Integer.parseInt(line[0]);
            int right = Integer.parseInt(line[1]);
            long start = left;
            long total = (right - left + 1) * (long) p;
            while (start <= right) {
                long div = p / start;
                if (div == 0) {
                    break;
                }
                long end = Math.min(p / div, right);
                total -= (end - start + 1) * (end + start) / 2 * div;
                start = end + 1;
            }
            sb.append(total).append("\n");
        }
        System.out.print(sb);
    }
}
0