Pagini recente » Cod sursa (job #2594321) | Cod sursa (job #1793000) | Cod sursa (job #1192621) | Cod sursa (job #94081) | Cod sursa (job #116762)
Cod sursa(job #116762)
Utilizator |
Andrei Grigorean wefgef |
Data |
19 decembrie 2007 14:39:03 |
Problema |
Bile2 |
Scor |
Ascuns |
Compilator |
cpp |
Status |
done |
Runda |
|
Marime |
0.82 kb |
#include <stdio.h>
const int n_max = 1000;
long long c[n_max][n_max],
p[n_max][n_max];
int i, j, n, d;
long long a, b;
int main()
{
freopen("bile2.in","r", stdin);
freopen("bile2.out", "w", stdout);
scanf("%d %d", &n, &d);
scanf("%lld %lld", &a, &b);
c[0][0] = 1;
for (i = 1; i <= n; ++ i)
{
p[1][i] = 1;
c[i][0] = 1;
for (j = 1; j <= i; ++ j)
c[i][j] = c[i-1][j-1] + c[i-1][j];
}
for (i = 2; i <= n; ++ i)
for (j = i; j <=n; ++ j)
p[i][j] = p[i][j-1] + p[i-1][j-d-1];
for (i = 2; i <= n; ++ i)
{
int sum = 0;
for (j = 1; j <= n; ++ j)
sum += p[i][j];
/* printf("i = %d sum = %d\n",i, sum);
fflush(stdout);
*/ if (((c[n][i]-sum)/c[n][i]) > (a/b))
{
printf("%d\n",i);
return 0;
}
}
printf("%d\n", (n/(d+1))+1);
return 0;
}