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

题意:很简单,看图片就能理解了。
水题一个!就不多解释了。

import java.util.Scanner;public class Main{public static void main(String[] args) {Scanner sc = new Scanner(System.in);int t = sc.nextInt();while(t-->0){String str = sc.next();int n = sc.nextInt();int m =sc.nextInt();if(str.charAt(0)=='A'){System.out.println(a(n,m));}else{System.out.println(c(n,m));}}}private static int c(int n, int m) {int num =1;if(n-m>m){m=n-m;}int cnum=1;for(int i=1;i<=n-m;i++){cnum=cnum*i;}for(int i=m+1;i<=n;i++){num=num*i;}return num/cnum;}private static int a(int n, int m) {int num=1;for(int i=n-m+1;i<=n;i++){num=num*i;}return num;}
}

HDOJ(HDU) 1570 A C相关推荐

  1. 题解报告:hdu 1570 A C

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1570 Problem Description Are you excited when you see ...

  2. HDOJ HDU 2080 夹角有多大II ACM 2080 IN HDU

    MiYu原创, 转帖请注明 : 转载自 ______________白白の屋 题目地址:          http://acm.hdu.edu.cn/showproblem.php?pid=2080 ...

  3. HDOJ HDU 1106 排序 ACM 1106 IN HDU

    //MiYu原创, 转帖请注明 : 转载自 ______________白白の屋 题目地址 :             http://acm.hdu.edu.cn/showproblem.php?pi ...

  4. HDOJ HDU 2058 The sum problem ACM 2058 IN HDU

    //MiYu原创, 转帖请注明 : 转载自 ______________白白の屋 题目地址 :          http://acm.hdu.edu.cn/showproblem.php?pid=2 ...

  5. HDOJ HDU 1709 The Balance ACM 1709 IN HDU

    //MiYu原创, 转帖请注明 : 转载自 ______________白白の屋 题目地址 :          http://acm.hdu.edu.cn/showproblem.php?pid=1 ...

  6. HDOJ HDU 1849 Rabbit and Grass ACM 1849 IN HDU

    MiYu原创, 转帖请注明 : 转载自 ______________白白の屋 题目地址:          http://acm.hdu.edu.cn/showproblem.php?pid=1849 ...

  7. HDOJ HDU 2088 Box of Bricks ACM 2088 IN HDU

    MiYu原创, 转帖请注明 : 转载自 ______________白白の屋 题目地址:          http://acm.hdu.edu.cn/showproblem.php?pid=2088 ...

  8. HDOJ HDU 1129 Do the Untwist

    HDOJ 1129 Do the Untwist 题目 点此查看 HDOJ 1129 Do the Untwist 分类 模拟 题意 模拟解密 字幕数字对照 "_" = 0, &q ...

  9. HDOJ(HDU) 2500 做一个正气的杭电人(水~)

    Problem Description 做人要有一身正气,杭电学子都应该如此.比如我们今天的考试就应该做到"诚信"为上. 每次考试的第一个题目总是很简单,今天也不例外,本题是要求输 ...

最新文章

  1. 编写矩形类 计算矩形面积
  2. Tomcat7启动报Error listenerStart错误--转载
  3. html编写输出学生姓名,用C++编写一个学生信息管理系统
  4. C#语言-04.OOP基础
  5. 02-微信小程序商城 顶部广告图片(微信小程序商城开发、小程序毕业设计、小程序源代码)(黄菊华-微信小程序开发教程)
  6. python中的stopwords_中文分词停止词stopwords词典,可下载
  7. C# WPF MVVM 实战 - 1
  8. 高德地图显示服务器加载失败,常见问题
  9. 【2017年总结】--吾生也有涯,而知也无涯
  10. 【原创】使用 Linux IO (LIO) 创建 SCSI target
  11. vue.js 的学习之路
  12. matlab对非平稳一维信号的小波变换
  13. 位数不足前面补0mysql语句_SQL语句 不足位数补0
  14. 服务器一般安装什么系统
  15. ajax添加header
  16. Win10,Win11系统安全中心提醒“找到可能不需要的应用”弹窗,如何关闭?
  17. LC滤波器设计学习笔记(一)滤波电路入门
  18. (ISC)² 2021年会暨网络安全峰会
  19. 贾跃亭不是老赖?网传贾跃亭已偿还200亿债务,你怎么看?...
  20. 分享:SET“红绳”悬吊运动训练的基本概念

热门文章

  1. 微软CTO谈AI:逃不掉马拉松就准备好跑鞋!30秒自动化妆机;ChatGPT刷爆票圈;剪纸风格的AI绘画 | ShowMeAI资讯日报
  2. CMAKE编译时如何自动下载第三方库并解压、安装到指定目录
  3. Android样式之drawable总结
  4. OpenSSL简单使用
  5. 使用WebMagic+ActiveMQ+Quartz实现全国城镇天气自动更新的API接口开发
  6. 微信自定义分享pc正常手机不正常
  7. 新兴游戏市场之——马来西亚
  8. 考研-计算机网络-第二章-物理层
  9. php内容管理系统 admini,BageCMS 开源网站内容管理系统 php版下载_BageCMS 开源网站内容管理系统 php版官方下载-太平洋下载中心...
  10. html文本分隔符,HTML快速入门8——HTML分隔符,一般语法,PRE标签,特殊字符显示...