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 x is 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.

——————————————————————-————————-——

题目的意思是给出两个数求这两个数的阶乘的gcd

思路:gcd一定是较小的数的阶乘

#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <queue>
#include <vector>
#include <set>
#include <stack>
#include <map>
#include <climits>
using namespace std; #define LL long long
const int INF = 0x3f3f3f3f;
int main()
{
int a[15],x,y;
a[1]=1;
for(int i=2;i<=12;i++)
a[i]=a[i-1]*i;
scanf("%d%d",&x,&y);
printf("%d\n",a[min(x,y)]);
return 0;
}

  

Codeforces822 A I'm bored with life的更多相关文章

  1. Codeforces822 B. Crossword solving

    B. Crossword solving time limit per test 1 second memory limit per test 256 megabytes input standard ...

  2. Codeforces Round #422 (Div. 2) A. I'm bored with life 暴力

    A. I'm bored with life     Holidays have finished. Thanks to the help of the hacker Leha, Noora mana ...

  3. By virtue of|sustain|post |scrape off |stretch|access to|take into account of|exploit|hasten|blur |idle|bored her to|account for|accused of|cruelty

    By virtue of this superior quality, this product is often sold out of stockin many areas. 我们的产品因其优秀的 ...

  4. bored

    https://icpcarchive.ecs.baylor.edu/index.php?option=com_onlinejudge&Itemid=8&page=show_probl ...

  5. [思维题]Bored Qishen

    给出一个整数集,其中包含1-n的所有整数,要求挑选出一个元素最多的子集,使得子集中任意两数的乘积不是完全平方数 (n<=10^6) 求这样一个最大子集的元素个数 #include <cst ...

  6. Gym 101102C Bored Judge(set--结构体集合)

    这个故事告诉我们,WA了一定要找自己的原因... ... 当我开始用set去做的时候,发现一直过不去,一开始忘了把初始排名加进去,后来忘了第0秒,第0秒第一的id = 1 这个题目的做法也不只这一种, ...

  7. Codeforces822 C. Hacker, pack your bags!

    C. Hacker, pack your bags! time limit per test 2 seconds memory limit per test 256 megabytes input s ...

  8. A - I'm bored with life

    Holidays have finished. Thanks to the help of the hacker Leha, Noora managed to enter the university ...

  9. 【Codeforces Round #422 (Div. 2) A】I'm bored with life

    [题目链接]:http://codeforces.com/contest/822/problem/A [题意] 让你求a!和b!的gcd min(a,b)<=12 [题解] 哪个小就输出那个数的 ...

随机推荐

  1. SpringMVC之controller篇1

    概述 继 Spring 2.0 对 Spring MVC 进行重大升级后,Spring 2.5 又为 Spring MVC 引入了注解驱动功能.现在你无须让 Controller 继承任何接口,无需在 ...

  2. andorid 菜单 进度条

    activity_ui2.xml <?xml version="1.0" encoding="utf-8"?> <LinearLayout x ...

  3. java8 数据结构的改变(一)

    在JDK1.6,JDK1.7中,HashMap采用数组+链表实现,即使用链表处理冲突,同一hash值的链表都存储在一个链表里.但是当数组中一个位置上的元素较多,即hash值相等的元素较多时,通过key ...

  4. Luogu 1641[SCOI2010]生成字符串 - 卡特兰数

    Description 有$N$ 个 $1$ 和 $M$ 个 $0$ 组成的字符串, 满足前 $k$ 个字符中 $1$ 的个数不少于 $0$ 的个数. 求这样字符串的个数. $1<=M < ...

  5. c++智能指针(1)

    根据muduo开源库作者陈硕的一些文章.对于多线程下C++编程提出了一些观点.主要是多线程下对象的销毁比较困难,但是由于多线程下,mutext是无法保护析构的.而后提出了智能指针的方案并对使用该指针会 ...

  6. CentOS7安装ms8可能出现的错误

    参照<在Centos上安装MS8.0的详细过程>:http://muchong.com/html/201507/9145663.html 安装过程中如果库文件不全,会异常终止.报错情况如下 ...

  7. Makefile 中@是什么意思

    http://bbs.chinaunix.net/thread-1916415-1-1.html linux源码的顶级Makefile中有这么一句 $(filter-out _all sub-make ...

  8. ubunut下安装ibus_pinyin中文输入法

    ubuntu安装中文输入法,,此处一ibus-pinyin为例为其安装中文输入法,,, 1. 设置(setting)---语言支持(language support)---汉语(chinese),,, ...

  9. 在python中while

    一.While循环 1.while循环格式 while 条件 : while循环体 当条件为Ture时,执行循环体,直到条件是假,停止循环. count = 1 # count 计数 一般用于计数 w ...

  10. yum 安装报错:Could not retrieve mirrorlist http://mirrorlist.centos.org/?release=7&arch=x86_64&repo=os&infra=stock error was 14: curl#6 - "Could not resolve host: mirrorlist.centos.org; Unknown error"

    [root@venn09 ~]# yum install -y vim Loaded plugins: fastestmirror Could not retrieve mirrorlist http ...