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. (转)Android EditText限制输入字符的5种实现方式

    最近项目要求限制密码输入的字符类型, 例如不能输入中文.   现在总结一下EditText的各种实现方式,  以比较各种方法的优劣. 第一种方式:  设置EditText的inputType属性,可以 ...

  2. Java 8.9 游戏:井字游戏(C++&Java)

    思路框架同8.20 : C++: #include<iostream> #include<string> using namespace std; class Chess { ...

  3. 发送邮件--MFMailComposeViewController

    只能在真机使用. 模拟器没有E-mail发送功能.无法调用 #import "EmailViewController.h" #import <UIKit/UIKit.h> ...

  4. for 循环分解

    for (expression1; expression2; expression3) { statement; } statement称为循环体 expression1为初始化部分,只在循环开始前执 ...

  5. PHP数组对象互转

    //数组转对象 function array2object($array) { if (is_array($array)) { $obj = new StdClass(); foreach ($arr ...

  6. Python Numpy中transpose()函数的使用

    在Numpy对矩阵的转置中,我们可以用transpose()函数来处理. 这个函数的运行是非常反常理的,可能会令人陷入思维误区. 假设有这样那个一个三维数组(2*4*2): array ([[[ 0, ...

  7. Netsharp下微信菜单以及OAuth

    一.OAuth介绍 在微信开发中,当打开一个页面是,业务场景一般会基于粉丝绑定用户信息,即页面需要基于粉丝和用户的身份处理业务逻辑. 在微信中打开一个页面有三个场景: 1.文本回复中直接包含url 2 ...

  8. MongoDB相关记录

    win10中zip安装 下载地址:http://dl.mongodb.org/dl/win32/x86_64 首先解压至某文件夹, 使用管理员权限打开cmd或者powershell, 进入指定目录中的 ...

  9. Git及其二次开发

    Git And TFS: 将 Visual Studio 用于 Git:http://msdn.microsoft.com/zh-cn/library/hh850437.aspx TFVC 和 Git ...

  10. spring学习 三 框架的搭建

    1 导入jar包 spring启来最少要5个包,四个核心包和一个依赖的日志包 2 创建配置文件 在dynamic web project下的src目录下,创建一个spring的xml配置文件,名称可以 ...