I'm bored with life (思维)

题目链接:http://codeforces.com/problemset/problem/822/A

思路:

刚开始傻乎乎的真的去算阶乘,然后再求它们的最大公约数。但是其实想一想,大的那个数的阶乘肯定包括小的那个数的阶乘。所以,它们的最大公约数就是小的那个数的阶乘。

 1 #include <iostream>
 2 #include <algorithm>
 3 #include <stdlib.h>
 4 #include <string>
 5 #include <string.h>
 6 #include <set>
 7 #include <queue>
 8 #include <stdbool.h>
 9 #include <map>
10 #define LL long long
11 using namespace std;
12 const int MAXN=100005;
13 
14 
15 int main()
16 {
17 #ifndef ONLINE_JUDGE
18     freopen("../in.txt","r",stdin);
19 #endif
20     int a,b,x,i,p=1;
21     scanf("%d %d",&a,&b);
22     x=a<b?a:b;
23     for(i=1;i<=x;i++)
24     {
25         p=p*i;
26     }
27     printf("%d
",p);
28     return 0;
29 }
原文地址:https://www.cnblogs.com/-Ackerman/p/11216263.html