A. I'm bored with life

time limit per test 1 second
memory limit per test 256 megabytes
input standard input
output standard output

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的更多相关文章

随机推荐

  1. shapefile的使用和地理信息的获得

    Shapefile文件是美国ESRI公司发布的文件格式,因其ArcGIS软件的推广而得到了普遍的使用,是现在GIS领域使用最为广泛的矢量数据格式.官方称Shapefile是一种用于存储地理要素的几何位 ...

  2. HDU - 2604 Queuing(递推式+矩阵快速幂)

    Queuing Time Limit: 10000/5000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Su ...

  3. python线程死锁与递归锁

    死锁现象 所谓死锁: 是指两个或两个以上的进程或线程在执行过程中,因争夺资源而造成的一种互相等待的现象,若无外力作用,它们都将无法推进下去. 此时称系统处于死锁状态或系统产生了死锁,这些永远在互相等待 ...

  4. 【xsy2272】 与运算 状压dp

    题目大意:给你一个长度为$n$的序列$a$,我们定义$f_i$表示序列$a$前i项一次进行按位与运算后的值. 我们认为一个序列的价值为$\sum_{i=1}^{n}f_i$,现在你要重新排列序列$a$ ...

  5. C# 发送HTTP请求超时解决办法

    request.GetResponse();超时问题的解决,和HttpWebRequest多线程性能问题,请求超时的错误, 解决办法 1.将http的request的keepAlive设置为false ...

  6. Jenkins配置自动打包 -- 遇到的坑

    1.把gradle路径设为本地路径 Jenkins部署在远程linux服务器上,使用git将代码下载到服务器路径下后,无法使用gradle命令 因为默认配置都是gradle同步时 实时从网上下载,进入 ...

  7. odoo开发笔记 -- 视图继承扩展

    参考: http://www.jeffzhang.cn/Odoo-Notes-2/ http://blog.csdn.net/zhangfeng1133/article/details/4693517 ...

  8. VS2015 WPF Prism Xaml Designer error

    Ref: http://wiki.tk2kpdn.com/build-error-prism5-interactionrequesttrigger-with-vs2015/ gacutil -i &q ...

  9. ssh-key的复制

    执行ssh-keygen 生产钥 在b主机root目录创建.ssh文件夹 在a主机输入ssh-copy-id root@*.*.*.* 就把公钥复制过去了 命令:scp 不同的Linux之间copy文 ...

  10. python使用(二)

    Python中的集合类型. 1.list_option.py 2.listsplit_option.py 3. dic_option.py 4.iter_option.py 1.list_option ...