結果

問題 No.799 赤黒かーどげぇむ
ユーザー ameame
提出日時 2019-03-17 21:29:43
言語 Java19
(openjdk 21)
結果
AC  
実行時間 134 ms / 2,000 ms
コード長 515 bytes
コンパイル時間 2,280 ms
コンパイル使用メモリ 72,212 KB
実行使用メモリ 55,968 KB
最終ジャッジ日時 2023-09-22 03:50:38
合計ジャッジ時間 6,197 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 132 ms
55,768 KB
testcase_01 AC 133 ms
55,620 KB
testcase_02 AC 130 ms
55,604 KB
testcase_03 AC 131 ms
55,616 KB
testcase_04 AC 129 ms
55,848 KB
testcase_05 AC 131 ms
55,604 KB
testcase_06 AC 131 ms
55,632 KB
testcase_07 AC 132 ms
55,456 KB
testcase_08 AC 131 ms
55,460 KB
testcase_09 AC 134 ms
55,776 KB
testcase_10 AC 134 ms
55,580 KB
testcase_11 AC 134 ms
55,968 KB
testcase_12 AC 128 ms
55,484 KB
testcase_13 AC 127 ms
55,728 KB
testcase_14 AC 131 ms
55,584 KB
testcase_15 AC 132 ms
55,592 KB
testcase_16 AC 133 ms
55,868 KB
testcase_17 AC 133 ms
55,664 KB
testcase_18 AC 133 ms
55,860 KB
testcase_19 AC 133 ms
55,532 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