Cod sursa(job #638160)
| Utilizator | Data | 20 noiembrie 2011 19:15:10 | |
|---|---|---|---|
| Problema | Minesweeper | Scor | 0 |
| Compilator | cpp | Status | done |
| Runda | .com 2011 | Marime | 0.56 kb |
#include <fstream>
#include <cstdlib>
#include <iomanip>
using namespace std;
ifstream f("minesweeper.in");
ofstream g("minesweeper.out");
int n,m,v[24],k,x,i,z;
double s;
int main () {
f >> n >> m;
n=n*m;s=2*n;k=1;
for (i=1;i<=80000;i++) {
x=rand()%n+1;
if (v[x]==2) z--;
v[x]=(v[x]+1)%3;
if (v[x]==2) z++;
if (z==n) {
s=s+(double)i/k;
k++;
}
}
s=(double)s/k;
g << fixed;
g << setprecision(6) << s;
f.close();g.close();
return 0;
}
