2683 Ohgas' Fortune

「2683 Ohgas' Fortune」の編集履歴(バックアップ)一覧はこちら

2683 Ohgas' Fortune」(2006/05/14 (日) 00:46:20) の最新版変更点

追加された行は緑色になります。

削除された行は赤色になります。

**2683 Ohgas' Fortune **解答例 import java.util.*; public class Main { public static void main(String[] args) { // TODO Auto-generated method stub Scanner sc = new Scanner(System.in); int m = sc.nextInt(); for(int i=0;i<m;i++){ int f = sc.nextInt(); int y = sc.nextInt(); int n = sc.nextInt(); int max = Integer.MIN_VALUE; for(int j=0;j<n;j++){ int mode = sc.nextInt(); double r = sc.nextDouble(); int c = sc.nextInt(); if(mode==0) max = Math.max(max, single(f, y, r, c)); else max = Math.max(max, compound(f, y, r, c)); } System.out.println(max); } } private static int single(int a, int year, double ratio, int charge){ int interest = 0; for(int i=0;i<year;i++){ interest += a * ratio; a -= charge; } return a + interest; } private static int compound(int a, int year, double ratio, int charge){ if(year==0) return a; else return compound(a + (int)(a * ratio) - charge, year - 1, ratio, charge); } }

表示オプション

横に並べて表示:
変化行の前後のみ表示:
ツールボックス

下から選んでください:

新しいページを作成する
ヘルプ / FAQ もご覧ください。