#include using namespace std; long long get_rand(long long lim,mt19937_64 &eg){ return (long long)(eg()%lim); } double prob[8][64]={0.0}; double sing[8]={0.0}; vector> field(36); double eval(){ double res=0; for(int i=0;i<6;i++){ vector bk(6,0); vector ok(6,1e9); int unk=0; for(int j=0;j<6;j++){ if(field[i*6+j].empty()){unk++;continue;} for(int k=0;k<6;k++){ bk[k]+=field[i*6+j][k]; ok[k]=min(ok[k],field[i*6+j][k]); } } for(int k=unk;k<=6*unk;k++){ for(int l=0;l<6;l++){ if(ok[l]>0){ double del=(k+bk[l]-3); res+=del*prob[unk][k]; } } } } for(int j=0;j<6;j++){ vector bk(6,0); vector ok(6,1e9); int unk=0; for(int i=0;i<6;i++){ if(field[i*6+j].empty()){unk++;continue;} for(int k=0;k<6;k++){ bk[k]+=field[i*6+j][k]; ok[k]=min(ok[k],field[i*6+j][k]); } } for(int k=unk;k<=6*unk;k++){ for(int l=0;l<6;l++){ if(ok[l]>0){ double del=(k+bk[l]-3); res+=del*prob[unk][k]; } } } } return res; } int main(){ std::random_device seed_gen; std::mt19937_64 engine(seed_gen()); sing[0]=1.0; for(int i=0;i<6;i++){ for(int j=i;j>=0;j--){ sing[i+1]+=sing[i]*(1.0/6.0); sing[i]*=(5.0/6.0); } } // for(int i=0;i<6;i++){cout << sing[i] << "\n";} prob[0][0]=1.0; for(int i=1;i<=6;i++){ for(int j=0;j<=6*(i-1);j++){ for(int k=1;k<=6;k++){ // at least one X prob[i][j+k]+=prob[i-1][j]*sing[k]; } } } for(int i=0;i<35;i++){ vector bk(6,0); for(int j=0;j<6;j++){ int v; cin >> v; v--; bk[v]++; } vector> sp; for(int i=0;i<6;i++){ for(int j=i;j<6;j++){ int f=(bk[i]+bk[j])*1000; if(bk[i]==0){f=bk[j];} if(bk[j]==0){f=bk[i];} sp.push_back({-f,36*get_rand(5000000,engine)+i*6+j}); } } sort(sp.begin(),sp.end()); int cur=-1; vector perm; for(int i=0;i<6;i++){perm.push_back(i);} shuffle(perm.begin(),perm.end(),engine); for(int i=0;i<6 && cur==-1;i++){ if(bk[perm[i]]>=3 && field[perm[i]*7].empty()){ cur=perm[i]*7; } } for(auto &nx : sp){ if(cur!=-1){break;} int tg; int u=(nx.second%36)/6; int v=nx.second%6; double euv=-1; tg=u*6+v; if(field[tg].empty()){ field[tg]=bk; euv=eval(); field[tg].clear(); } double evu=-1; tg=v*6+u; if(field[tg].empty()){ field[tg]=bk; evu=eval(); field[tg].clear(); } if(euv