Cod sursa(job #637990)

Utilizator tzipleatudTudor Tiplea tzipleatud Data 20 noiembrie 2011 18:00:57
Problema Minesweeper Scor 0
Compilator cpp Status done
Runda .com 2011 Marime 0.55 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<=70;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+=i;
            k++;
        }
    }
    s=(double)s/k;
    g << fixed;
    g << setprecision(6) << s;
    f.close();g.close();
    return 0;
}