#include<cstdio>
#include<algorithm>
using namespace std;
double permutation(long int n,long int r)
{
int i,k;
double num;
if(r==0)
return 1;
k=min(r,n-r);
num=1;
for(i=k;i>=1;i--)
{
num=num*(n-i+1);
num=num/i;
}
return num;
}
int main()
{
long int n,r,t,a[10000],i;
double g;
while(scanf("%ld%ld",&n,&r)==2)
{
if(n==0&&r==0)
break;
g=permutation(n,r);
for(i=1;;i++)
{
g=g/(double)(10);
t=g;
if(t==0)
break;
}
printf("%ld\n",i);
}
return 0;
}
#include<algorithm>
using namespace std;
double permutation(long int n,long int r)
{
int i,k;
double num;
if(r==0)
return 1;
k=min(r,n-r);
num=1;
for(i=k;i>=1;i--)
{
num=num*(n-i+1);
num=num/i;
}
return num;
}
int main()
{
long int n,r,t,a[10000],i;
double g;
while(scanf("%ld%ld",&n,&r)==2)
{
if(n==0&&r==0)
break;
g=permutation(n,r);
for(i=1;;i++)
{
g=g/(double)(10);
t=g;
if(t==0)
break;
}
printf("%ld\n",i);
}
return 0;
}
No comments:
Post a Comment