Codeforces822 A I'm bored with life
1 second
256 megabytes
standard input
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?
The first and single line contains two integers A and B (1 ≤ A, B ≤ 109, min(A, B) ≤ 12).
Print a single integer denoting the greatest common divisor of integers A! and B!.
4 3
6
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的更多相关文章
- Codeforces822 B. Crossword solving
B. Crossword solving time limit per test 1 second memory limit per test 256 megabytes input standard ...
- 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 ...
- 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. 我们的产品因其优秀的 ...
- bored
https://icpcarchive.ecs.baylor.edu/index.php?option=com_onlinejudge&Itemid=8&page=show_probl ...
- [思维题]Bored Qishen
给出一个整数集,其中包含1-n的所有整数,要求挑选出一个元素最多的子集,使得子集中任意两数的乘积不是完全平方数 (n<=10^6) 求这样一个最大子集的元素个数 #include <cst ...
- Gym 101102C Bored Judge(set--结构体集合)
这个故事告诉我们,WA了一定要找自己的原因... ... 当我开始用set去做的时候,发现一直过不去,一开始忘了把初始排名加进去,后来忘了第0秒,第0秒第一的id = 1 这个题目的做法也不只这一种, ...
- 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 ...
- A - I'm bored with life
Holidays have finished. Thanks to the help of the hacker Leha, Noora managed to enter the university ...
- 【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 [题解] 哪个小就输出那个数的 ...
随机推荐
- PHP开发——常见问题
执行顺序 常见数据类型 字符乱码
- if 循环的深入理解 哈希表的一种应用
哈希表的值作为一个颜色容器,值默认为标识1, 表示未曾用过,若用过标识为0: 1: 程序第一步 遍历哈希表,查找标识为1 未曾用过的颜色 我用了这个: string colorno_us ...
- hdu 1735(贪心) 统计字数
戳我穿越:http://acm.hdu.edu.cn/showproblem.php?pid=1735 对于贪心,二分,枚举等基础一定要掌握的很牢,要一步一个脚印走踏实 这是道贪心的题目,要有贪心的意 ...
- RNA测序相对基因表达芯片有什么优势?
RNA测序相对基因表达芯片有什么优势? RNA-Seq和基因表达芯片相比,哪种方法更有优势?关键看适用不适用.那么RNA-Seq适用哪些研究方向?是否您的研究?来跟随本文了解一下RNA测序相对基因表达 ...
- codeforces 数字区分 搜索
Jokewithpermutation Input file: joke.inOutput file: joke.outJoey had saved a permutation of integers f ...
- php7.0-fpm.sock
.sock 这种方式是套接字的方式连接的
- java 内存, 类加载g
1. java 内存区域 方法区 虚拟机栈 本地方法栈 堆 程序计数器 其中 : 方法区 和 堆 是所有线程共享的 , 其他是线程隔离的 1. 程序计数器 : 可以看做是当前线程所执行的字节码的 ...
- Map 概述
map定义:将键映射到值的对象.key必须唯一,但是value可以重复.当你添加相同key的值的时候,value会被覆盖. 与之前的collection有什么区别呢? A:Map 存储的是键值对形式的 ...
- tomcat+bean例子
C:\Program Files\Apache Software Foundation\Tomcat 7.0\webapps\app\WEB-INF\classes\文件夹下 建立beanTestPa ...
- 之前的一些Oracle的经验总结
1. 安装: 1) 关于字符集的选择,现在还不很了解,修改是需要进入一个模式下才可以修改,当然新建一个数据库实例的时候可以重新设定: UTF8是相对比较大的一个字符集, 可以简单实用这个就能保存很多的 ...