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.
问题链接:https://cn.vjudge.net/contest/276590#problem/C
问题简述:求两个数的公约数
问题分析:求的是两个阶乘数的公约数,理解偏题目意思,实际上都是阶乘那么最大公约数一定是小的阶乘 非常简单的一个题目,却被我搞复杂
- 当时可能心态有问题 不是很冷静下来分析题目
- 对题目的分析有待提高
程序说明:
程序如下:
#include<iostream>
using namespace std;
int main()
{
int A, B, sum1, sum2;
cin >> A >> B;
sum1 = 1; sum2 = 1;
for (int i = 1; i <= A; i++)
{
sum1 = sum1 * i;
}
for (int i = 1; i <= B; i++)
{
sum2 = sum2 * i;
}
if (A >= B)cout << sum2;
else cout << sum1;
system(" PAUSE");
return 0;
}
网友评论