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. DZY Loves Math(莫比乌斯反演)

    \(x=p_1^{\alpha_1}p_2^{\alpha_2}...p_c^{\alpha_c}\) \(f(x)=\max(\alpha_1,\alpha_2,...,\alpha_c)\) \( ...

  2. 28_网络编程-TCP/UDP

    一.传输层       1.定义       IP首部有一个协议字段,用来标识网络层(IP)的上一层所采用的是哪一种传输层协议.根据这个字段的协议号,就可以识别IP传输的数据部分究竟是TCP的内容还是 ...

  3. cad2017卸载/安装失败/如何彻底卸载清除干净cad2017注册表和文件的方法

    cad2017提示安装未完成,某些产品无法安装该怎样解决呢?一些朋友在win7或者win10系统下安装cad2017失败提示cad2017安装未完成,某些产品无法安装,也有时候想重新安装cad2017 ...

  4. cookie、session的区别

    相信你肯定经常听说cookie和Session,那你有没有好好了解这两个的区别呢?其实,不整理之前,我也是一脸懵. 为什么需要cookie和session呢?---因为Http是无状态的,web开发中 ...

  5. windows10升级系统后,无法远程桌面连接服务器

    远程桌面,身份验证错误:要求的函数不正确等解决办法 https://www.cnblogs.com/LuckWJL/p/9018710.html

  6. 课程一(Neural Networks and Deep Learning),第四周(Deep Neural Networks) —— 3.Programming Assignments: Deep Neural Network - Application

    Deep Neural Network - Application Congratulations! Welcome to the fourth programming exercise of the ...

  7. Java reflect 反射学习笔记

    1. class 类的使用 万事万物皆对象 (基本数据类型, 静态成员不是面向对象), 所以我们创建的每一个类都是对象, 即类本身是java.lang.Class类的实例对象, 但是这些对象不需要 n ...

  8. 【Java初探外篇02】——关于静态方法与实例方法

    在Java的学习中,我们知道,方法的使用是不可或缺的重要部分,在我们编写第一个Java程序hello world的时候,我们就要开始使用主方法main():它就是一个静态方法(static metho ...

  9. mysql笔记-索引

    什么是聚簇索引 聚簇索引:索引的叶节点就是数据节点(索引值).而非聚簇索引的叶节点仍然是索引节点(告诉你怎么在表中查找这一记录),只不过有一个指针指向对应的数据块. Innodb和MyIsam区别 转 ...

  10. 配置Codis-Service主机

    Codis-Service配置在三台机器上,每台机器分别配置3个redis,如下: ip:(redis-.redis-.redis-) ip:(redis-.redis-.redis-) ip:(re ...