結果

問題 No.23 技の選択
ユーザー ぴろず
提出日時 2014-12-19 10:46:11
言語 Java
(openjdk 23)
結果
AC  
実行時間 135 ms / 5,000 ms
コード長 510 bytes
コンパイル時間 2,032 ms
コンパイル使用メモリ 74,920 KB
実行使用メモリ 41,552 KB
最終ジャッジ日時 2024-06-28 16:45:47
合計ジャッジ時間 7,313 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 33
権限があれば一括ダウンロードができます

ソースコード

diff #

package no023;

import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		double p = 0;
		double x = 2/3D;
		for(int i=1;i<=100;i++) {
			p += x * i;
			x /= 3;
		}
		Scanner sc = new Scanner(System.in);
		int h = sc.nextInt();
		int a = sc.nextInt();
		int d = sc.nextInt();
		double[] dp = new double[h+1];
		for(int i=1;i<=h;i++) {
			if (i <= a) {
				dp[i] = 1;
			}else{
				dp[i] = Math.min(dp[i-a]+1,dp[Math.max(i-d,0)]+p);
			}
		}
		System.out.println(dp[h]);
	}

}
0