結果

問題 No.740 幻の木
ユーザー htensai
提出日時 2020-05-13 11:41:12
言語 Java
(openjdk 23)
結果
AC  
実行時間 134 ms / 2,000 ms
コード長 618 bytes
コンパイル時間 2,106 ms
コンパイル使用メモリ 77,332 KB
実行使用メモリ 41,508 KB
最終ジャッジ日時 2024-09-14 15:29:40
合計ジャッジ時間 4,014 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 6
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		int p = sc.nextInt();
		int q = sc.nextInt();
		int[] arr = new int[13];
		int total = 0;
		for (int i = 1; i <= 12; i++) {
		    if (i >= p && i < p + q) {
		        arr[i] = m * 2;
		    } else {
		        arr[i] = m;
		    }
		    total += arr[i];
		}
		int year = n / total;
		n -= total * year;
		int month = year * 12;
		int idx = 1;
		while (n > 0) {
		    n -= arr[idx];
		    idx++;
		    month++;
		}
		System.out.println(month);
	}
}
0