Thursday, July 30, 2015

1005 - Rooks

#include<bits/stdc++.h>
using namespace std;
 
int main()
{
    unsigned long long T,n,k,ans,c=1,i;
    cin >> T;
 
    while(T--)
    {
        cin >> n >> k;
        ans = 1;
        if(n<k)
        {
            cout << "Case " << c++ << ": 0" << endl;
            continue;
        }
        for(i=1; i<=k; i++)
        {
            ans = ans*n*n/i;
            n -= 1;
        }
        cout << "Case " << c++ << ": " << ans << endl;
 
    }
    return 0;
}

No comments:

Post a Comment

Triathlon

Triathlon - CodeChef # include < bits/stdc++.h > using namespace std ; # define fi first # define se second # define mp ...