ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1402. Cocktails

Please tell me what is wrong in my programm???????????!!!!
Posted by Atbasar(GBK) 8 Jan 2010 22:05
#include <iostream.h>
long int fac(long int k)
{
    int i,total=1;
    if(k==0)
    {
        return 1;
    }
    for(i=1;i<=k;i++)
    {
        total*=i;
    }
    return total;
}
int main()
{
    long int n,total=0,i;
    cin>>n;
    {
        if(n<14)
        {
            for(i=2;i<=n;i++)
    {
        total+=fac(n)/fac(n-i);
    }
            cout<<total<<endl;
        }
    }
    if(n>14&&n<17)
    {
        for(i=2;i<=n;i++)
    {
        total+=fac(n)/fac(n-i);
    }
        cout<<total<<endl;
    }
    if(n==14)
    {
        cout<<"87178291200"<<endl;
    }
    if(n==17)
    {
        cout<<"355687428096000"<<endl;
    }
    if(n==18)
    {
        cout<<"6402373705728000"<<endl;
    }
    if(n==19)
    {
        cout<<"121645100408832000"<<endl;
    }
    if(n==20)
    {
        cout<<"2432902008176640000"<<endl;
    }
    if(n==21)
    {
        cout<<"51090942171709440000"<<endl;
    }
    return 0;
}
Re: Please tell me what is wrong in my programm???????????!!!!
Posted by Ras Misha [t4ce] 8 Jan 2010 23:44
for example for 21 answer is 138879579704209680000