Codeforces Round #422 (Div. 2) 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?
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.
题意:
给你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 暴力的更多相关文章
- Codeforces Round #422 (Div. 2)
Codeforces Round #422 (Div. 2) Table of Contents Codeforces Round #422 (Div. 2)Problem A. I'm bored ...
- 【Codeforces Round #422 (Div. 2) D】My pretty girl Noora
[题目链接]:http://codeforces.com/contest/822/problem/D [题意] 有n个人参加选美比赛; 要求把这n个人分成若干个相同大小的组; 每个组内的人数是相同的; ...
- 【Codeforces Round #422 (Div. 2) C】Hacker, pack your bags!(二分写法)
[题目链接]:http://codeforces.com/contest/822/problem/C [题意] 有n个旅行计划, 每个旅行计划以开始日期li,结束日期ri,以及花费金钱costi描述; ...
- 【Codeforces Round #422 (Div. 2) B】Crossword solving
[题目链接]:http://codeforces.com/contest/822/problem/B [题意] 让你用s去匹配t,问你最少需要修改s中的多少个字符; 才能在t中匹配到s; [题解] O ...
- 【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 [题解] 哪个小就输出那个数的 ...
- 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 ...
- 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 ...
- 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 ...
- 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 ...
随机推荐
- get 发送ajax请求
上demo小案例 <!DOCTYPE html> <html> <head> <meta charset="utf-8"> < ...
- 用docker弹性部署自己的服务
很久不看docker的东西了,之前了解的一些基本命令都忘得差不多了,适逢工作需要,再来复习巩固下.今天想完成的是:借助docker不部署下自己的服务. 环境准备 都说“巧妇难为无米之炊”,所以还是需要 ...
- log4j详细配置解析
出自:http://www.blogjava.net/zJun/archive/2006/06/28/55511.html Log4J的配置文件(Configuration File)就是用来设置记录 ...
- 洛谷 [P3265] 装备购买
线性基 通过题目描述可以感觉到就是要求线性基, 线性基的求法是高斯消元,消完以后剩下的x的系数非 0 的就是线性基 本题有一个贪心策略,每次挑选价格最小的来消掉其他的元 //可以快排预处理 #incl ...
- Struts2标签-checkbox只读属性设置
Struts2标签-checkbox只读属性设置 在struts2的checkbox标签中,为实现只读效果,一般使用readonly="true"是达不到效果的,但设置disabl ...
- UI小结
第一.UIButton的定义 UIButton *button=[[UIButton buttonWithType:(UIButtonType); 能够定义的button类型有以下6种, ...
- eopkg命令
#命令: add-repo (ar) ---添加存储库 blame (bl) ---包所有者和发布信息 build (bi) ---建立eopkg包 check ---验证安装 clean ...
- electron 编译成exe
前提:现在有一个electron项目,等待打包成exe. 一,运行”electron .“,看运行是否正常.不正常则继续调试,正常可进入到第二步. 二,运行“electron-packager . m ...
- 嵌入式cpu架构
原文:http://www.kaixin001.com/repaste/11007221_7220618944.html### 内容: 目前主要CPU架构有ARM.X86/Atom.MIPS.Powe ...
- 存code
#include<cstdio> #include<cstring> #include<iostream> #include<algorithm> us ...