結果

問題 No.352 カード並べ
ユーザー GrenacheGrenache
提出日時 2016-03-11 23:48:49
言語 Java21
(openjdk 21)
結果
AC  
実行時間 138 ms / 2,000 ms
コード長 794 bytes
コンパイル時間 5,207 ms
コンパイル使用メモリ 74,708 KB
実行使用メモリ 57,744 KB
最終ジャッジ日時 2023-10-25 06:03:29
合計ジャッジ時間 5,637 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 135 ms
57,492 KB
testcase_01 AC 138 ms
57,560 KB
testcase_02 AC 133 ms
57,744 KB
testcase_03 AC 135 ms
57,620 KB
testcase_04 AC 128 ms
57,248 KB
testcase_05 AC 133 ms
57,560 KB
testcase_06 AC 136 ms
57,456 KB
testcase_07 AC 131 ms
57,528 KB
testcase_08 AC 131 ms
57,648 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;


public class Main_yukicoder352 {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();

//        long[] fact = new long[n + 1];
//        fact[0] = 1;
//        for (int i = 1; i <= n; i++) {
//        	fact[i] = fact[i - 1] * i;
//        }

        double ret = 2;
        for (int i = 3; i <= n; i++) {
        	int m = i - 1;
        	double tmp = (double)2 / (m + 1);
        	for (int j = 1; j <= m; j++) {
        		for (int k = j + 1; k <= m; k++) {
        			if (j == k) {
        				continue;
        			}

        			tmp += (double)2 * j * k / m / (m + 1);
        		}
        	}

        	ret += tmp;
        }

        System.out.printf("%.7f\n", ret);

        sc.close();
    }
}
0