Cod sursa(job #1314025)
| Utilizator | Data | 11 ianuarie 2015 14:19:47 | |
|---|---|---|---|
| Problema | Cifre | Scor | 60 |
| Compilator | cpp | Status | done |
| Runda | Arhiva de probleme | Marime | 0.57 kb |
#include <fstream>
#include <iostream>
#include <ctime>
#include <cstdlib>
using namespace std;
ifstream fin ("cifre.in");
ofstream fout ("cifre.out");
const int R = 850000;
int a, b, c, k, sol;
int main() {
fin >> a >> b >> c >> k;
srand ((unsigned) time(0));
for (int r = 0; r < R; ++r) {
int x = a + rand() % (b - a + 1), now = 0;
while (x) {
if (x % 10 == c)
now++;
x /= 10;
}
if (now >= k)
sol++;
}
fout << 1.0 * sol / R ;
}