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. PTA 09-排序3 Insertion or Heap Sort (25分)

    题目地址 https://pta.patest.cn/pta/test/16/exam/4/question/676 5-14 Insertion or Heap Sort   (25分) Accor ...

  2. caffe+vs2013+window10+GPU(CPU)配置

    参考:http://www.echojb.com/cuda/2017/03/15/350138.html https://www.zhihu.com/question/56111727 第一步:首先确 ...

  3. Terracotta2

    Terracotta 3.2.1简介 (二) Terracotta分布式缓存EhcacheQuartzTerracotta的web session方案  高效.高可用的Web Session解决方案 ...

  4. Web Services 教程

    Web Services 可使您的应用程序成为 Web 应用程序. Web Services 通过 Web 进行发布.查找和使用. Web Services 是应用程序组件 Web Services  ...

  5. Spell Boost

    Spell Boost 时间限制: 1 Sec  内存限制: 128 MB 题目描述 Shadowverse is a funny card game. One day you are playing ...

  6. ZOJ - 3816 Generalized Palindromic Number dfs

    Generalized Palindromic Number Time Limit: 2 Seconds                                     Memory Limi ...

  7. Java 新手的通病

    一:对算法和数据结构不熟悉 为什么我先拿“数据结构和算法”说事捏?这玩意是写程序最最基本的东东.不管你使用 Java 还是其它的什么语言,都离不开它.而且这玩意是跨语言的,学好之后不管在哪门语言中都能 ...

  8. LibieOJ 6165 一道水题 (线性筛)

    题目链接 LOJ6165 题目意思其实就是求LCM(1, 2, 3, ..., n) 直接用线性筛求出1到1e8之间的所有质数 然后对于每个质数p,他对答案的贡献为$p^{i}$ 其中$p^{i}$小 ...

  9. Codeforces Gym 100286J Javanese Cryptoanalysis 傻逼暴力

    原题地址:http://codeforces.com/gym/100286/attachments/download/2013/20082009-acmicpc-northeastern-europe ...

  10. 解决Eclipse中SVN版本信息不显示的问题

    eclipse  中使用 svn 插件,原本正常,未作任何更改,最近几天突然eclipse 中查看文件时,文件后面的 版本号 . 文件的状态图标 等等都不见了.以为有插件冲突,卸载了好多其他的相关的插 ...