結果

問題 No.352 カード並べ
ユーザー 37zigen37zigen
提出日時 2016-03-12 01:53:48
言語 Java21
(openjdk 21)
結果
AC  
実行時間 167 ms / 2,000 ms
コード長 548 bytes
コンパイル時間 3,614 ms
コンパイル使用メモリ 76,200 KB
実行使用メモリ 57,928 KB
最終ジャッジ日時 2023-10-25 06:23:36
合計ジャッジ時間 5,778 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 160 ms
57,664 KB
testcase_01 AC 161 ms
57,928 KB
testcase_02 AC 159 ms
57,928 KB
testcase_03 AC 162 ms
57,684 KB
testcase_04 AC 162 ms
57,924 KB
testcase_05 AC 162 ms
57,908 KB
testcase_06 AC 152 ms
57,056 KB
testcase_07 AC 166 ms
57,800 KB
testcase_08 AC 167 ms
57,604 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

package 練習;
import java.util.Date;
import java.util.Scanner;
public class main{
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		double n=sc.nextDouble();
		long exec_time=new Date().getTime();
		double prd=0;
		double e_prd=0;
		double e_cost=1;
		for(double i=2;i<=n;i++){;
			if(i>2)
				e_prd=prd/((i-1)*(i-2));//積の平均
			e_cost+=2/i+e_prd*(i-2)/i;
			prd+=(i-1)*i*i;//1~iまでの2数の積の和
		}
		
		System.out.println(e_cost);
		System.err.println(new Date().getTime()-exec_time+"ms");

	}
}
0