A. I'm bored with life
 
 

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.

题意:

  给你A,B,求出其阶乘的GCD

题解:

  min(A,B)<=12

  暴力吧

#include<bits/stdc++.h>
using namespace std;
#pragma comment(linker, "/STACK:102400000,102400000")
#define ls i<<1
#define rs ls | 1
#define mid ((ll+rr)>>1)
#define pii pair<int,int>
#define MP make_pair
typedef long long LL;
const long long INF = 1e18+1LL;
const double pi = acos(-1.0);
const int N = +, M = 1e3+,inf = 2e9; int a,b;
int main() {
scanf("%d%d",&a,&b);
LL ans = ;
for(int i = ; i <= min(a,b); ++i) {
ans *= 1LL*i;
}
cout<<ans<<endl;
return ;
}

Codeforces Round #422 (Div. 2) A. I'm bored with life 暴力的更多相关文章

  1. Codeforces Round #422 (Div. 2)

    Codeforces Round #422 (Div. 2) Table of Contents Codeforces Round #422 (Div. 2)Problem A. I'm bored ...

  2. 【Codeforces Round #422 (Div. 2) D】My pretty girl Noora

    [题目链接]:http://codeforces.com/contest/822/problem/D [题意] 有n个人参加选美比赛; 要求把这n个人分成若干个相同大小的组; 每个组内的人数是相同的; ...

  3. 【Codeforces Round #422 (Div. 2) C】Hacker, pack your bags!(二分写法)

    [题目链接]:http://codeforces.com/contest/822/problem/C [题意] 有n个旅行计划, 每个旅行计划以开始日期li,结束日期ri,以及花费金钱costi描述; ...

  4. 【Codeforces Round #422 (Div. 2) B】Crossword solving

    [题目链接]:http://codeforces.com/contest/822/problem/B [题意] 让你用s去匹配t,问你最少需要修改s中的多少个字符; 才能在t中匹配到s; [题解] O ...

  5. 【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 [题解] 哪个小就输出那个数的 ...

  6. Codeforces Round #422 (Div. 2)E. Liar sa+st表+dp

    题意:给你两个串s,p,问你把s分开顺序不变,能不能用最多k段合成p. 题解:dp[i][j]表示s到了前i项,用了j段的最多能合成p的前缀是哪里,那么转移就是两种,\(dp[i+1][j]=dp[i ...

  7. Codeforces Round #422 (Div. 2) E. Liar 后缀数组+RMQ+DP

    E. Liar     The first semester ended. You know, after the end of the first semester the holidays beg ...

  8. Codeforces Round #422 (Div. 2) D. My pretty girl Noora 数学

    D. My pretty girl Noora     In Pavlopolis University where Noora studies it was decided to hold beau ...

  9. Codeforces Round #422 (Div. 2) C. Hacker, pack your bags! 排序,贪心

    C. Hacker, pack your bags!     It's well known that the best way to distract from something is to do ...

随机推荐

  1. zabbix的安装(一)监控os资源:内存,cpu,io,负载,带宽

    一.Linux下开源监控系统简单介绍1)cacti:存储数据能力强,报警性能差2)nagios:报警性能差,存储数据仅有简单的一段可以判断是否在合理范围内的数据长度,储存在内存中.比如,连续采样数据存 ...

  2. 【Luogu】P2158仪仗队(欧拉函数)

    题目链接 首先来介绍欧拉函数. 设欧拉函数为f(n),则f(n)=1~n中与n互质的数的个数. 欧拉函数有三条引论: 1.若n为素数,则f(n)=n-1; 2.若n为pa,则f(n)=(p-1)*(p ...

  3. apache kafka参考

    apache kafka参考 消息队列分类:  点对点: 消息生产者生产消息发送到queue中,然后消息消费者从queue中取出并且消费消息.这里要注意: 消息被消费以后,queue中不再有存储,所以 ...

  4. XPosed框架_简单的应用

    0. Xposed框架简介 关于Xposed框架相信大家应该不陌生了,他是Android中Hook技术的一个著名的框架,而Xposed框架是免费的而且还是开源的,本文主要介绍如何通过这个框架来进行系统 ...

  5. 最长递增子序列(cogs 731)

    «问题描述:给定正整数序列x1,..., xn.(1)计算其最长递增子序列的长度s.(2)计算从给定的序列中最多可取出多少个长度为s的递增子序列.(3)如果允许在取出的序列中多次使用x1和xn,则从给 ...

  6. 【AIM Tech Round 5 (Div. 1 + Div. 2) 】

    A:https://www.cnblogs.com/myx12345/p/9844152.html B:https://www.cnblogs.com/myx12345/p/9844205.html ...

  7. list或map 打印成json 方便调试

    private final Logger logger = Logger.getLogger(this.getClass()); logger.info(JSON.toJSONStringWithDa ...

  8. springmvc中ajax处理

    1.使用HttpServletResponse处理--不需要配置解析器 @Controller public class AjaxController { @RequestMapping(" ...

  9. Bruce Eckel:编程生涯

    大家总是问一个错误的问题:“我应该学习C++还是Java?”在本文中,我将告诉大伙儿:对于选择编程生涯真正需要关注的是哪些问题. 请注意,这篇文章的目标读者并不是那些已经做出自己选择的人.(对于这些人 ...

  10. jQuery.ajax()方法中參数具体解析

    前言 在项目开发中,为了实现异步向服务端发起请求,最常常使用的就是jQuery.ajax方法了.刚開始需求比較简单,调用jQuery.ajax方法时要传的參数也就那几个常见的參数:url/data/d ...