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 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 = 533333+10, M = 1e3+20,inf = 2e9;

int a,b;
int main() {
    scanf("%d%d",&a,&b);
    LL ans = 1;
    for(int i = 1; i <= min(a,b); ++i) {
        ans *= 1LL*i;
    }
    cout<<ans<<endl;
    return 0;
}

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

时间: 2024-12-18 01:18:32

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

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

题目链接:Codeforces Round #422 (Div. 2) D. My pretty girl Noora 题意: 给你一个数n和t,l,r,让你求 t0·f(l)?+?t1·f(l?+?1)?+?...?+?tr?-?l·f(r). 其中f(n)是n个人的最少比较次数. 比如n为4,可以先2 2分,然后胜出2个人,最后再比较一次,所以f(4)=3. f(3)=3,因为3为质数,只能这样分. 题解: 这题半天没看清楚题意啊.- -!以为是任意分. 结果是选一个数x,每组都必须为x个人

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

链接: http://codeforces.com/contest/822/problem/C 题意: 有x天的假期, 有n张旅行票, 每张票有起始时间l, 结束时间r, 花费cost, 想把假期分成两部分出去旅游, 两部分时间不能重合(ri < lj || rj < li), 问最小花费是多少, 如果不能两部分, 输出-1 题解: CF官方解法, 效率O(nlogn2) 设置一个结构体, struct P{int p, len, cost, type}; 将每张票(l, r, cost) 表

Codeforces Round #422 (Div. 2) C Hacker, pack your bags!

It's well known that the best way to distract from something is to do one's favourite thing. Job is such a thing for Leha. So the hacker began to work hard in order to get rid of boredom. It means that Leha began to hack computers all over the world.

Codeforces Round #422 (Div. 2) A-C

A. I'm bored with life 水题 #include <iostream> #include <cstring> #include <cstdio> #include <algorithm> #include <queue> #include <vector> #include <iomanip> #include <math.h> #include <map> using name

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 begin. On holidays Noora decided to return to Vi?kopolis. As a modest souvenir for Leha, she brought a sausage of length m from Pavlopolis. Everyone knows th

Codeforces Round #422 (Div. 2)

A: 给你两个数 (最小的那个<=12)  问这两个数阶乘的GCD 我都吓傻了 直接fac(min(a,b)) 搞定 //By SiriusRen #include <bits/stdc++.h> using namespace std; int A,B; long long t=1; int main(){ scanf("%d%d",&A,&B); if(A>B)swap(A,B); for(int i=1;i<=A;i++)t=t*i;

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 one's favourite thing. Job is such a thing for Leha. So the hacker began to work hard in order to get rid of boredom. It means that Leha began to hack co

Codeforces Round #262 (Div. 2) E. Roland and Rose 暴力

E. Roland and Rose Time Limit: 1 Sec  Memory Limit: 256 MB 题目连接 http://codeforces.com/problemset/problem/460/E Description Roland loves growing flowers. He has recently grown a beautiful rose at point (0, 0) of the Cartesian coordinate system. The ro

Codeforces Round #312 (Div. 2) A. Lala Land and Apple Trees 暴力

A. Lala Land and Apple Trees Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/558/problem/A Description Amr lives in Lala Land. Lala Land is a very beautiful country that is located on a coordinate line. Lala Land is famous