結果
| 問題 | No.108 トリプルカードコンプ |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2015-05-12 21:20:18 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
CE
(最新)
AC
(最初)
|
| 実行時間 | - |
| コード長 | 957 bytes |
| コンパイル時間 | 145 ms |
| コンパイル使用メモリ | 29,020 KB |
| 最終ジャッジ日時 | 2024-11-14 19:03:08 |
| 合計ジャッジ時間 | 729 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
コンパイルエラー時のメッセージ・ソースコードは、提出者また管理者しか表示できないようにしております。(リジャッジ後のコンパイルエラーは公開されます)
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:24:3: error: ‘vector’ was not declared in this scope
24 | vector<int> x(3);
| ^~~~~~
main.cpp:3:1: note: ‘std::vector’ is defined in header ‘<vector>’; did you forget to ‘#include <vector>’?
2 | #include <algorithm>
+++ |+#include <vector>
3 | using namespace std;
main.cpp:24:10: error: expected primary-expression before ‘int’
24 | vector<int> x(3);
| ^~~
main.cpp:27:17: error: ‘x’ was not declared in this scope
27 | if(a < 3) { x[a]++; }
| ^
main.cpp:29:20: error: ‘x’ was not declared in this scope
29 | printf("%f\n", E[x[0]][x[1]][x[2]]);
| ^
main.cpp:11:15: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
11 | int n; scanf("%d", &n);
| ~~~~~^~~~~~~~~~
main.cpp:26:17: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
26 | int a; scanf("%d", &a);
| ~~~~~^~~~~~~~~~
ソースコード
#include <cstdio>
#include <algorithm>
using namespace std;
class range {private: struct I{int x;int operator*(){return x;}bool operator!=(I& lhs){return x<lhs.x;}void operator++(){++x;}};I i,n;
public:range(int n):i({0}),n({n}){}range(int i,int n):i({i}),n({n}){}I& begin(){return i;}I& end(){return n;}};
double E[111][111][111];
int main(void) {
int n; scanf("%d", &n);
for(int k0 : range(n+1)) {
for(int k1 : range(n+1)) {
for(int k2 : range(n+1)) {
int k = k0 + k1 + k2;
if(k == 0) { continue; }
E[k0][k1][k2] = double(n) / k;
if(k0 > 0) { E[k0][k1][k2] += E[k0-1][k1+1][k2] * k0 / k; }
if(k1 > 0) { E[k0][k1][k2] += E[k0] [k1-1][k2+1] * k1 / k; }
if(k2 > 0) { E[k0][k1][k2] += E[k0] [k1] [k2-1] * k2 / k; }
}
}
}
vector<int> x(3);
for(int i : range(n)) {
int a; scanf("%d", &a);
if(a < 3) { x[a]++; }
}
printf("%f\n", E[x[0]][x[1]][x[2]]);
return 0;
}