Cod sursa(job #636580)

Utilizator tzipleatudTudor Tiplea tzipleatud Data 19 noiembrie 2011 21:26:10
Problema Minesweeper Scor 0
Compilator cpp Status done
Runda .com 2011 Marime 0.59 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=2;//3*1000*1000/n;
    for (i=1;i<200;i++) {
        z=0;
        while (z!=n) {
            x=rand()%n+1;
            if (v[x]==2) z--;
            v[x]=(v[x]+1)%3;
            if (v[x]==2) z++;
            s++;
        }
    }
    s=(double)s/k;
    g << fixed;
    g << setprecision(6) << s;
    f.close();g.close();
    return 0;
}