結果
問題 | No.108 トリプルカードコンプ |
ユーザー |
|
提出日時 | 2020-03-02 22:02:36 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 10 ms / 5,000 ms |
コード長 | 550 bytes |
コンパイル時間 | 525 ms |
コンパイル使用メモリ | 69,504 KB |
実行使用メモリ | 8,832 KB |
最終ジャッジ日時 | 2024-10-13 21:18:53 |
合計ジャッジ時間 | 1,459 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 20 |
コンパイルメッセージ
main.cpp:16:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type] 16 | main() | ^~~~
ソースコード
#include<iostream> #include<iomanip> using namespace std; double dp[101][101][101]; bool vis[101][101][101]; int N; double f(int x,int y,int z) { if(x<0||y<0||z<0||x+y+z>N)return 0; if(vis[x][y][z])return dp[x][y][z]; if(!x&&!y&&!z)return 0; dp[x][y][z]=(x*f(x-1,y+1,z)+y*f(x,y-1,z+1)+z*f(x,y,z-1)+N)/(double)(x+y+z); vis[x][y][z]=true; return dp[x][y][z]; } main() { cin>>N; int I=0,J=0,K=0; for(int i=0;i<N;i++) { int A;cin>>A; if(A==0)I++; else if(A==1)J++; else if(A==2)K++; } cout<<fixed<<setprecision(16)<<f(I,J,K)<<endl; }