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. 正则表达式 re sys os random time 模块

    今天学习内容如下: 1.正则表达式 百度正则表达式在线测试,可以练习 正则表达式本身也和python没有什么关系,就是匹配字符串内容的一种规则.官方定义:正则表达式是对字符串操作的一种逻辑公式,就是用 ...

  2. spring boot (二):使用fastJson解析json数据

    如果我们想在spring boot中使用第三方的json解析框架: 1)我们需要在pom.xml文件中引入第三方包的依赖; 2)实现方法: 方法1 需要在启动类中继承WebMvcConfigurerA ...

  3. node.js 在使用child_process 模块时候,调试端口占用的问题解决方案(EADDRINUSE)

    在fork的时候,带参数{ execArgv: ['--debug=' + (process.debugPort +   1)] }

  4. 02. pt-archiver

    pt-archiver \--source h=192.168.100.101,P=3306,u=admin,p='admin',D=db01,t=t01 \--dest h=192.168.100. ...

  5. 超级好看!巧用PS将风光人像打造成唯美的小星球效果!

    本篇教大家如何巧用PS将风光人像照片打造成唯美的小星球!教程讲解过程很细致,理论实操简单易懂,最终完成效果灰常的漂亮,喜欢的小伙伴赶快收走学起来吧! 原图: 效果图: PS:1.对齐图像,选中所有图, ...

  6. 学习C语言以及C语言基础调查

    学习声乐的心得 你有什么技能比大多人(超过90%以上)更好?   就我个人而言,在所有的兴趣之中,做得比较好的应该属于声乐. 针对这个技能的获取你有什么成功的经验?   我对于声乐处始于兴趣,成功的经 ...

  7. vue动态路由配置,vue路由传参

    动态路由: 当我们很多个页面或者组件都要被很多次重复利用的时候,我们的路由都指向同一个组件,这时候从不同组件进入一个"共用"的组件,并且还要传参数,渲染不同的数据 这就要用到动态路 ...

  8. 学习python 多进程和多线程

    ''' 学习多进程和多线程 ''' import multiprocessing def deadLoop(): while True: pass if __name__ == '__main__': ...

  9. VisualStudio2017密钥(key)我随便输入一下居然通过了?????????!!!!!!!!!!!!

    VisualStudio2017密钥(key) 2017年12月30日 14:41:38 阅读数:5048 professional:KBJFW-NXHK6-W4WJM-CRMQB-G3CDH ent ...

  10. 【WebService】WebService之WSDL文档深入分析(三)

    WSDL概念 WSDL(网络服务描述语言,Web Services Description Language)是一门基于 XML 的语言,用于描述 Web Services 以及如何对它们进行访问. ...