MY name is ruhul amin

ISLAMIC UNIVERSITY OF KUSHTIA

Saturday, March 2, 2013

uva solve problem 10219_finds the ways

#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;
}

No comments:

Post a Comment