Pagini recente » Cod sursa (job #1588921) | Cod sursa (job #3289554) | Cod sursa (job #1879813) | Cod sursa (job #2230159) | Cod sursa (job #1280638)
//"Nu specific toate detaliile" - Explicatie oficiala
#include <fstream>
#include <iostream>
#include <ctime>
#include <cstdlib>
using namespace std;
ifstream fin ("cifre.in");
ofstream fout ("cifre.out");
const int R = 950000;
int a, b, c, k, sol;
int get(int x) {
int now = 0;
while (x) {
if (x % 10 == c)
now++;
x /= 10;
}
if (now >= k)
return 1;
return 0;
}
int main() {
fin >> a >> b >> c >> k;
if (b - a <= 1e6 + 1)
for (int x = a; x <= b; ++x)
sol += get(x);
if (sol) {
fout << 1.0 * sol / (b - a + 1);
return 0;
}
srand ((unsigned) time(0));
for (int r = 0; r < R; ++r) {
int x = a + rand() % (b - a + 1);
sol += get(x);
}
fout << 1.0 * sol / R ;
}