結果

問題 No.574 正多面体サイコロ
ユーザー koba-e964koba-e964
提出日時 2016-11-16 21:35:10
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 11 ms / 2,000 ms
コード長 891 bytes
コンパイル時間 621 ms
コンパイル使用メモリ 61,668 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-17 07:34:56
合計ジャッジ時間 1,924 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 3 ms
4,376 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 3 ms
4,376 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 5 ms
4,380 KB
testcase_10 AC 5 ms
4,376 KB
testcase_11 AC 2 ms
4,376 KB
testcase_12 AC 2 ms
4,376 KB
testcase_13 AC 2 ms
4,380 KB
testcase_14 AC 2 ms
4,376 KB
testcase_15 AC 1 ms
4,376 KB
testcase_16 AC 2 ms
4,380 KB
testcase_17 AC 3 ms
4,376 KB
testcase_18 AC 4 ms
4,376 KB
testcase_19 AC 2 ms
4,376 KB
testcase_20 AC 2 ms
4,380 KB
testcase_21 AC 1 ms
4,376 KB
testcase_22 AC 11 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cmath>
#include <cassert>
#include <iostream>

#define REP(i,s,n) for(int i=(int)(s);i<(int)(n);i++)

using namespace std;

const int N = 200;
double fact[N];

int main(void){
  int f, n, k;
  cin >> f >> n >> k;
  assert (f == 4 || f == 6 || f == 8 || f == 12 || f == 20);
  assert (1 <= n);
  assert (n <= 100);
  assert (1 <= k);
  assert (k <= n);
  fact[0] = 1;
  REP(i, 1, N) {
    fact[i] = fact[i - 1] * i;
  }
  double sum = 0;
  REP(i, 1, f + 1) {
    // k-th value is i
    REP(j, 0, k) {
      // we have j values in range i + 1 .. f
      REP(l, 1, n + 1) {
	// we have l values that are i
	if (j < k && j + l >= k && j + l <= n) {
	  double tmp = (j == 0 ? 1 : pow(f - i, j))
	    * (l == 0 ? 1 : pow(i - 1, n - j - l));
	  tmp /= pow(f, n);
	  tmp *= fact[n] / fact[j] / fact[l] / fact[n - j - l];
	  sum += tmp * i;
	}
      }
    }
  }
  printf("%.15f\n", sum);
}
0