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\n",p);
28     return 0;
29 }

 

全部评论

相关推荐

2025-12-18 19:36
已编辑
门头沟学院 Java
程序员牛肉:可以的,简历没毛病了。 虽然还是偏向同质化,不过学历不错。后续我觉得重心放到刷实习+摆脱同质化问题上
实习简历求拷打
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务