結果

問題 No.352 カード並べ
ユーザー 🍡yurahuna🍡yurahuna
提出日時 2016-03-11 23:24:57
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 765 bytes
コンパイル時間 1,313 ms
コンパイル使用メモリ 159,400 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-25 05:57:29
合計ジャッジ時間 1,872 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 1 ms
4,348 KB
testcase_02 AC 1 ms
4,348 KB
testcase_03 AC 2 ms
4,348 KB
testcase_04 AC 2 ms
4,348 KB
testcase_05 AC 2 ms
4,348 KB
testcase_06 AC 2 ms
4,348 KB
testcase_07 AC 1 ms
4,348 KB
testcase_08 AC 1 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
#define rrep2(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define all(a) (a).begin(),(a).end()

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<P> vp;
typedef vector<ll> vll;

signed main() {
    int N;
    cin >> N;
    double ans = 2;
    rep2(k, 3, N + 1) {
        ans += 2.0 * 1 / k;
        double temp = 0;
        rep2(j, 1, k) {
            rep2(i, 1, j) {
                temp += i * j;
            }
        }
        temp /= 1.0 * (k - 1) * (k - 2) / 2;
        temp *= (1 - 2.0 / k);
        ans += temp;
    }
    printf("%.10f\n", ans);

}
0