Hangzhou Electric HDU 1570 A C

Source: Internet
Author: User

A C Time limit:2000/1000 MS (java/others) Memory limit:32768/32768 K (java/others)
Total submission (s): 4206 Accepted Submission (s): 2671


Problem Descriptionare You excited the title "AC"? If The answer is YES, AC it;

You must learn these and combination formulas in the school. If you had forgotten it, see the picture.




Now I'll give you N and M, and your task was to calculate the answer.
Inputin the first line, there is a integer T indicates the number of the test cases.
Then T-cases follows in the T lines.
Each case contains a character ' a ' or ' C ', the integers represent N and M. (1<=n,m<=10)
Outputfor each case, if the character are ' a ', calculate a (m,n), and if the character is ' C ', calculate C (m,n).
and print the answer in a.
Sample Input
2 a 10C 4 2

Sample Output
36288006

Authorlinle
Sourcehdu 2007-1 Programming Contest Harbin Life is also drunk, put a fake bored to brush this problem play.
#include <iostream>using namespace std;int fac (int k) {int sum=1;for (int i=1;i<=k;i++) Sum*=i;return sum;} int main () {int N,n,m;char ch;cin>>n;while (n--) {cin>>ch>>n>>m;if (ch== ' A ') COUT<<FAC (n )/(FAC (N-M)) <<endl;else if (ch== ' C ') COUT<<FAC (N)/(FAC (M) *FAC (n-m)) <<endl;} return 0;}

Hangzhou Electric HDU 1570 A C

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.