結果

問題 No.959 tree and fire
ユーザー 37zigen37zigen
提出日時 2020-03-18 22:59:23
言語 Java21
(openjdk 21)
結果
AC  
実行時間 142 ms / 2,000 ms
コード長 1,033 bytes
コンパイル時間 3,571 ms
コンパイル使用メモリ 74,756 KB
実行使用メモリ 57,892 KB
最終ジャッジ日時 2023-08-20 20:22:45
合計ジャッジ時間 12,297 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 135 ms
55,932 KB
testcase_01 AC 138 ms
57,564 KB
testcase_02 AC 137 ms
55,764 KB
testcase_03 AC 137 ms
55,888 KB
testcase_04 AC 138 ms
55,636 KB
testcase_05 AC 138 ms
55,544 KB
testcase_06 AC 138 ms
56,024 KB
testcase_07 AC 140 ms
55,764 KB
testcase_08 AC 139 ms
55,908 KB
testcase_09 AC 137 ms
55,540 KB
testcase_10 AC 137 ms
55,696 KB
testcase_11 AC 137 ms
55,916 KB
testcase_12 AC 135 ms
55,972 KB
testcase_13 AC 136 ms
55,988 KB
testcase_14 AC 137 ms
55,904 KB
testcase_15 AC 136 ms
56,084 KB
testcase_16 AC 136 ms
55,772 KB
testcase_17 AC 135 ms
55,784 KB
testcase_18 AC 137 ms
56,244 KB
testcase_19 AC 137 ms
56,044 KB
testcase_20 AC 136 ms
56,196 KB
testcase_21 AC 137 ms
55,972 KB
testcase_22 AC 138 ms
55,652 KB
testcase_23 AC 135 ms
55,784 KB
testcase_24 AC 137 ms
55,792 KB
testcase_25 AC 142 ms
55,652 KB
testcase_26 AC 138 ms
56,000 KB
testcase_27 AC 137 ms
55,844 KB
testcase_28 AC 139 ms
55,836 KB
testcase_29 AC 139 ms
56,164 KB
testcase_30 AC 139 ms
56,240 KB
testcase_31 AC 139 ms
55,852 KB
testcase_32 AC 138 ms
55,620 KB
testcase_33 AC 137 ms
56,132 KB
testcase_34 AC 137 ms
56,064 KB
testcase_35 AC 138 ms
56,060 KB
testcase_36 AC 138 ms
56,156 KB
testcase_37 AC 136 ms
55,988 KB
testcase_38 AC 137 ms
53,968 KB
testcase_39 AC 136 ms
55,648 KB
testcase_40 AC 137 ms
55,844 KB
testcase_41 AC 141 ms
55,944 KB
testcase_42 AC 141 ms
55,888 KB
testcase_43 AC 138 ms
55,868 KB
testcase_44 AC 137 ms
55,652 KB
testcase_45 AC 135 ms
55,668 KB
testcase_46 AC 136 ms
56,164 KB
testcase_47 AC 137 ms
56,304 KB
testcase_48 AC 138 ms
55,884 KB
testcase_49 AC 136 ms
55,756 KB
testcase_50 AC 137 ms
55,936 KB
testcase_51 AC 135 ms
55,664 KB
testcase_52 AC 137 ms
57,892 KB
testcase_53 AC 136 ms
55,796 KB
testcase_54 AC 139 ms
55,668 KB
testcase_55 AC 139 ms
56,144 KB
testcase_56 AC 139 ms
55,752 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Arrays;
import java.util.Comparator;
import java.util.PriorityQueue;
import java.util.Scanner;

class Main {

	public static void main(String[] args) {
		new Main().run();
	}
	
	double pow(double a,long n) {
		double ret=1;
		for(;n>0;n/=2,a*=a)if(n%2==1)ret*=a;
		return ret;
	}

	void run() {
		Scanner sc = new Scanner(System.in);
		long n=sc.nextInt();
		long m=sc.nextInt();
		double p=sc.nextDouble();
		long center=Math.max(n-2, 0)*Math.max(m-2, 0);
		long lateral_side=Math.max(m-2,0)*Math.min(n,2);
		long vertical_side=Math.max(n-2, 0)*Math.min(m,2);
		long corner=Math.min(2, n)*Math.min(2, m);
		long area_center=5;
		long area_corner=1+Math.min(n-1,1)+Math.min(m-1,1);
		long area_lateral_side=3+Math.min(n-1, 1);
		long area_vertical_side=3+Math.min(m-1, 1);
		System.out.println(center*pow(p,area_center)+corner*pow(p,area_corner)+lateral_side*pow(p,area_lateral_side)+vertical_side*pow(p,area_vertical_side));
	}

	void tr(Object... objects) {
		System.out.println(Arrays.deepToString(objects));
	}
}
0