CodeForces822A
A. I'm bored with life
Holidays have finished. Thanks to the help of the hacker Leha, Noora managed to enter the university of her dreams which is located in a town Pavlopolis. It's well known that universities provide students with dormitory for the period of university studies. Consequently Noora had to leave Vičkopolis and move to Pavlopolis. Thus Leha was left completely alone in a quiet town Vičkopolis. He almost even fell into a depression from boredom!
Leha came up with a task for himself to relax a little. He chooses two integers A and B and then calculates the greatest common divisor of integers "A factorial" and "B factorial". Formally the hacker wants to find out GCD(A!, B!). It's well known that the factorial of an integer xis a product of all positive integers less than or equal to x. Thus x! = 1·2·3·...·(x - 1)·x. For example 4! = 1·2·3·4 = 24. Recall that GCD(x, y) is the largest positive integer q that divides (without a remainder) both x and y.
Leha has learned how to solve this task very effective. You are able to cope with it not worse, aren't you?
Input
The first and single line contains two integers A and B (1 ≤ A, B ≤ 109, min(A, B) ≤ 12).
Output
Print a single integer denoting the greatest common divisor of integers A! and B!.
Example
input
4 3
output
6
Note
Consider the sample.
4! = 1·2·3·4 = 24. 3! = 1·2·3 = 6. The greatest common divisor of integers 24 and 6 is exactly 6.
很久没写题,来一发水题看看自己还会不会写题了。。。
//2017-07-11
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm> using namespace std; long long arr[]; int main()
{
int a, b;
arr[] = ;
for(int i = ; i < ; i++){
arr[i] = arr[i-]*i;
}
while(cin>>a>>b){
cout<<arr[min(a, b)]<<endl;
} return ;
}
CodeForces822A的更多相关文章
随机推荐
- Spring Boot log4j多环境日志级别的控制
之前介绍了在<Spring boot中使用log4j>,仅通过log4j.properties对日志级别进行控制,对于需要多环境部署的环境不是很方便,可能我们在开发环境大部分模块需要采用D ...
- Swift5 语言指南(二十八) 高级运算符
除了Basic Operators中描述的运算符之外,Swift还提供了几个执行更复杂值操作的高级运算符.这些包括C和Objective-C中您熟悉的所有按位和位移运算符. 与C中的算术运算符不同,S ...
- mongodb 初学 意外 连接服务器异常(Connection refused)
啦啦啦 这种情况 root@localhost:/# mongo MongoDB shell version: connecting to: test --31T07:: W NETWORK [thr ...
- python爬虫在解析不带引号的json报错的问题解决方案
本例中环境: python3.6.6 demjson-2.2.4 如不看废话请直接看3(下面红体字) 1.近期在爬取代理验证代理的时候发生一个Bug, 就是在验证代理的时候返回的是如下字符串, {ip ...
- 【liferay】5、使用PortletURL进行跨portlet通信 liferay6.2
[问题] 1.当我们一个页面存在多一个portlet的时候,如在不同的portlet之间传参? [解决办法] 1.在liferay官方有几种方式,比较复杂麻烦,不是太实用,这里不再赘述. 2.通过fr ...
- [umbraco] 数据结构
我想此图就能说明一切了,不需要再废话了
- xamarin 编译出现Xamarin.Build.Forms.Tasks.GetTaskAbi 无法加载的错误解决方法
最新升级最新的vs2017后发现编译xamarin forms 会出现错误 Xamarin.Forms.Build.Tasks.GetTasksAbi task could not be loaded ...
- Docker概念学习系列之虚拟化(系统虚拟化和容器虚拟化)
不多说,直接上干货! 虚拟化定义: 虚拟化是一种资源管理技术,是将计算机的各种实体资源,如服务器.网络.内存及存储等,予以抽象.转换后呈现出来,打破实体结构间的不可切割的障碍,使用户可以比原本的配置更 ...
- Centos7下安装redis实战(单机版以及集群)
一.背景 因项目需要,要引入redis做缓存,就在centos7下亲自安装了一遍redis,刚好趁着这个机会就来把redis的概念以及单机版和集群版redis安装步骤记录下来,在此和大家一起分享. 二 ...
- axios跨域post请求后台参数为null
查了一个小时的资料,大部分都是说设置headers 可能是我查找的关键词不对吧,最后找到一篇文章,把问题解决了 前端解决方式 官方文档 后台解决方式 教程参考地址:http://blog.csdn. ...