Saturday, 1 October 2011

ACM 10219-Find the ways !

#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<string>
#include<cctype>
#include<stack>
#include<queue>
#include<vector>
#include<map>
#include<set>
#include<sstream>
#include<utility>
#include<math.h>
#include<stdio.h>
#include<ctype.h>
using namespace std;

int main()
{
    long double n,r,i,digitn,digitr;
    //freopen("in.txt","r",stdin);
    while(scanf("%Lf%Lf",&n,&r)==2)
    {
        digitn=0,digitr=0;
        for(i=r;i>=1;i--)
        {
            digitn+=log10(n--);
            digitr+=log10(i);
        }
        cout<<floor(digitn-digitr)+1<<endl;
    }
    return 0;
}

1 comment: