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 1066. Garland

Why my program can not be accepted??
Posted by Danli 20 May 2009 11:16
#include<iostream.h>
#include<math.h>
int ji(int n);
int main()
{
    int k,n,m,c,a;
    int d=0;
    cin>>n>>k;
    if((k>=2&&k<=10)&&n>=2&&(n+k)<=18)
    {
        m=0;
        if(n%2==1)
        while(m<(n+1)/2)
        {
            c=ji(n-m);
            a=ji(m);
            d=d+int(pow(k-1,n-m-1)*c/a/ji(n-m-m));
            m++;
        }
        else
        while(m<=(n+1)/2)
        {
            c=ji(n-m);
            a=ji(m);
            d=d+int(pow(k-1,n-m-1)*c/a/ji(n-m-m));
            m++;
        }
        cout<<(k-1)*d<<endl;
    }
    return 0;
}

int ji(int n)
{
    if(n==0)
        return 1;
    else
        return n*ji(n-1);
}