結果

問題 No.799 赤黒かーどげぇむ
ユーザー Grenache
提出日時 2019-04-26 15:03:09
言語 Java
(openjdk 23)
結果
AC  
実行時間 125 ms / 2,000 ms
コード長 737 bytes
コンパイル時間 2,941 ms
コンパイル使用メモリ 74,564 KB
実行使用メモリ 41,568 KB
最終ジャッジ日時 2024-11-24 12:10:45
合計ジャッジ時間 6,186 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 20
権限があれば一括ダウンロードができます

ソースコード

diff #

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


public class Main_yukicoder799 {

	private static Scanner sc;
	private static Printer pr;

	private static void solve() {
		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 (i >= c && i <= d) {
				ans += d - c;
			} else {
				ans += d - c + 1;
			}
		}
		
		pr.println(ans);
	}

	// ---------------------------------------------------
	public static void main(String[] args) {
		sc = new Scanner(System.in);
		pr = new Printer(System.out);
			
		solve();
			
		pr.close();
		sc.close();
	}

	static class Printer extends PrintWriter {
		Printer(OutputStream out) {
			super(out);
		}
	}
}
0