結果
| 問題 | No.108 トリプルカードコンプ |
| コンテスト | |
| ユーザー |
sugim48
|
| 提出日時 | 2014-11-14 19:52:32 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 14 ms / 5,000 ms |
| コード長 | 710 bytes |
| コンパイル時間 | 418 ms |
| コンパイル使用メモリ | 24,832 KB |
| 実行使用メモリ | 9,636 KB |
| 最終ジャッジ日時 | 2024-12-31 10:50:53 |
| 合計ジャッジ時間 | 1,352 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 20 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:7:21: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
7 | int N; scanf("%d", &N);
| ~~~~~^~~~~~~~~~
main.cpp:20:29: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
20 | int A; scanf("%d", &A);
| ~~~~~^~~~~~~~~~
ソースコード
#include <cstdio>
using namespace std;
double dp[101][101][101];
int main() {
int N; scanf("%d", &N);
for (int k0 = 0; k0 <= N; k0++)
for (int k1 = 0; k1 <= N; k1++)
for (int k2 = 0; k2 <= N; k2++) {
int k = k0 + k1 + k2;
if (k == 0) continue;
dp[k0][k1][k2] = (double)N / k;
if (k0 > 0) dp[k0][k1][k2] += dp[k0 - 1][k1 + 1][k2] * k0 / k;
if (k1 > 0) dp[k0][k1][k2] += dp[k0][k1 - 1][k2 + 1] * k1 / k;
if (k2 > 0) dp[k0][k1][k2] += dp[k0][k1][k2 - 1] * k2 / k;
}
int k0 = 0, k1 = 0, k2 = 0;
for (int i = 0; i < N; i++) {
int A; scanf("%d", &A);
if (A == 0) k0++;
if (A == 1) k1++;
if (A == 2) k2++;
}
printf("%.10f\n", dp[k0][k1][k2]);
}
sugim48