結果

問題 No.799 赤黒かーどげぇむ
ユーザー tentententen
提出日時 2020-12-09 18:08:05
言語 Java21
(openjdk 21)
結果
AC  
実行時間 144 ms / 2,000 ms
コード長 465 bytes
コンパイル時間 2,104 ms
コンパイル使用メモリ 75,280 KB
実行使用メモリ 57,716 KB
最終ジャッジ日時 2023-10-19 05:03:09
合計ジャッジ時間 5,842 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 137 ms
57,120 KB
testcase_01 AC 132 ms
57,588 KB
testcase_02 AC 131 ms
57,292 KB
testcase_03 AC 133 ms
57,532 KB
testcase_04 AC 132 ms
57,180 KB
testcase_05 AC 132 ms
57,500 KB
testcase_06 AC 136 ms
57,380 KB
testcase_07 AC 133 ms
57,380 KB
testcase_08 AC 132 ms
57,716 KB
testcase_09 AC 132 ms
57,164 KB
testcase_10 AC 132 ms
57,092 KB
testcase_11 AC 129 ms
57,524 KB
testcase_12 AC 133 ms
57,552 KB
testcase_13 AC 132 ms
55,592 KB
testcase_14 AC 141 ms
57,176 KB
testcase_15 AC 144 ms
57,672 KB
testcase_16 AC 140 ms
57,584 KB
testcase_17 AC 143 ms
57,404 KB
testcase_18 AC 132 ms
57,024 KB
testcase_19 AC 133 ms
57,412 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        int d = sc.nextInt();
        long ans = 0;
        for (int i = a; i <= b; i++) {
            ans += d - c + 1;
            if (i >= c && i <= d) {
                ans--;
            }
        }
        System.out.println(ans);
    }
}
0