Mai intai trebuie sa te autentifici.
Cod sursa(job #1990357)
| Utilizator | Data | 11 iunie 2017 15:40:01 | |
|---|---|---|---|
| Problema | Cifre | Scor | 70 |
| Compilator | cpp | Status | done |
| Runda | Arhiva de probleme | Marime | 0.68 kb |
#include <stdio.h>
#include <cstdlib>
#include <ctime>
#include<iostream>
using namespace std;
int a, b, c, k;
int proc(int aux)
{
return a+aux%(b-a+1);
}
int nrcif(int x, int c)
{
int nr=0;
while(x!=0)
{
if(x%10==c) nr++;
x=x/10;
}
return nr;
}
int main()
{
int ans=0;
freopen("cifre.in", "r", stdin);
freopen("cifre.out", "w", stdout);
scanf("%d%d%d%d", &a, &b, &c, &k);
srand(time(NULL));
for(int i=1; i<=1000000; i++)
{
int aux=rand();
aux=proc(aux);
if(nrcif(aux, c)>=k) ans++;
}
printf("%.4f ", (float)ans/1000000);
return 0;
}
