hdu 1570 AC

A C

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 4830    Accepted Submission(s): 3115

Problem Description

Are you excited when you see the title "AC" ? If the answer is YES , AC it ;
You must learn these two combination formulas in the school . If you have forgotten it , see the picture.

Now I will give you n and m , and your task is to calculate the answer .

Input

In the first line , there is a integer T indicates the number of test cases. Then T cases follows in the T lines. Each case contains a character ‘A‘ or ‘C‘, two integers represent n and m. (1<=n,m<=10)

Output

For each case , if the character is ‘A‘ , calculate A(m,n),and if the character is ‘C‘ , calculate C(m,n). And print the answer in a single line.

Sample Input

2

A 10 10

C 4 2

Sample Output

3628800

6

 1 #include <iostream>
 2 using namespace std;
 3 int f[11] = {1, 1};
 4
 5
 6 int main(){
 7     for(int i = 2; i < 11; i++){
 8         f[i] = i * f[i-1];
 9     }
10     int test, n, m;
11     char c;
12     cin >> test;
13     while(test--){
14         cin >> c >> n >> m;
15         if(c == ‘A‘)
16             cout << f[n] / f[n - m] << endl;
17         else if(c == ‘C‘)
18             cout << f[n] / f[m] / f[n - m] << endl;
19     }
20     return 0;
21 }
时间: 2024-10-29 19:08:33

hdu 1570 AC的相关文章

hdu 2896 AC自动机

// hdu 2896 AC自动机 // // 题目大意: // // 给你n个短串,然后给你q串长字符串,要求每个长字符串中 // 是否出现短串,出现的短串各是什么 // // 解题思路: // // AC自动机,插入单词,构建自动机,然后查询就可以了. // // 感悟: // // 哎,自己AC自动机果然刚学,还只会个模板,自动机构没构建 // 都不知道...继续加油吧~~~FIGHTING! #include <cstdio> #include <cstring> #inc

hdu 2296 aC自动机+dp(得到价值最大的字符串)

Ring Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 3180    Accepted Submission(s): 1033 Problem Description For the hope of a forever love, Steven is planning to send a ring to Jane with a rom

hdu 2457 AC自动机+dp

DNA repair Time Limit: 5000/2000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 2004    Accepted Submission(s): 1085 Problem Description Biologists finally invent techniques of repairing DNA that contains segments c

HDU 1219: AC Me

HDU 1219: AC Me ///@author Sycamore, ZJNU ///@accepted_on 2017-01-24 #include<iostream> #include<string> #include <algorithm> using namespace std; int main() { string s; while (getline(cin, s)) { for (int i = 0; i < 26; i++) { cout &l

hdu 2825 aC自动机+状压dp

Wireless Password Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 5640    Accepted Submission(s): 1785 Problem Description Liyuan lives in a old apartment. One day, he suddenly found that there

hdu 3247 AC自动+状压dp+bfs处理

Resource Archiver Time Limit: 20000/10000 MS (Java/Others)    Memory Limit: 100000/100000 K (Java/Others)Total Submission(s): 2382    Accepted Submission(s): 750 Problem Description Great! Your new software is almost finished! The only thing left to

hdu 3065 AC自动机(各子串出现的次数)

病毒侵袭持续中 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 10324    Accepted Submission(s): 3633 Problem Description 小t非常感谢大家帮忙解决了他的上一个问题.然而病毒侵袭持续中.在小t的不懈努力下,他发现了网路中的“万恶之源”.这是一个庞大的病毒网站,他有着好多好多的病毒,但

hdu 3992 AC自动机上的高斯消元求期望

Crazy Typewriter Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 391    Accepted Submission(s): 109 Problem Description There was a crazy typewriter before. When the writer is not very sober, it

hdu 5880 AC自动机

Family View Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 175    Accepted Submission(s): 20 Problem Description Steam is a digital distribution platform developed by Valve Corporation offering