結果

問題 No.799 赤黒かーどげぇむ
ユーザー ameame
提出日時 2019-03-17 21:29:43
言語 Java17
(openjdk 17.0.1)
結果
AC  
実行時間 95 ms / 2,000 ms
コード長 515 bytes
コンパイル時間 2,313 ms
使用メモリ 42,368 KB
最終ジャッジ日時 2023-02-11 04:17:35
合計ジャッジ時間 5,541 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
使用メモリ
testcase_00 AC 93 ms
40,384 KB
testcase_01 AC 91 ms
40,432 KB
testcase_02 AC 91 ms
40,164 KB
testcase_03 AC 90 ms
42,224 KB
testcase_04 AC 90 ms
42,260 KB
testcase_05 AC 93 ms
40,440 KB
testcase_06 AC 95 ms
38,764 KB
testcase_07 AC 91 ms
40,336 KB
testcase_08 AC 92 ms
40,164 KB
testcase_09 AC 92 ms
42,368 KB
testcase_10 AC 91 ms
40,344 KB
testcase_11 AC 91 ms
40,304 KB
testcase_12 AC 90 ms
42,344 KB
testcase_13 AC 91 ms
40,396 KB
testcase_14 AC 90 ms
42,316 KB
testcase_15 AC 93 ms
40,320 KB
testcase_16 AC 90 ms
42,132 KB
testcase_17 AC 93 ms
42,088 KB
testcase_18 AC 91 ms
40,372 KB
testcase_19 AC 94 ms
42,104 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

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();
        int ans = 0;
        for (int i = a; i <= b; i++) {
            if (c <= i && i <= d) {
                ans += d - c;
            } else {
                ans += d - c + 1;
            }
        }
        System.out.println(ans);
        sc.close();
    }
}
0