Common Divisors CodeForces - 1203C
2024-09-06 17:17:18
题意:
给你n个数,让你找出来公因子有多少个。公因子:对于这n个数,都能被这个公因子整除
题解:
只需要找出来这n个数的最大公因子x,然后找出来有多少不同数能把x给整。(因为我们可以保证x可以把这n个数整除,又因为x是最大公因数,那么能把x整除的数肯定也可以把这n个数整除)
代码:
1 #include<stdio.h>
2 #include<string.h>
3 #include<iostream>
4 #include<algorithm>
5 #include<queue>
6 #include<map>
7 #include<vector>
8 #include<math.h>
9 #define mem(a,x) memset(a,x,sizeof(a))
10 using namespace std;
11 typedef long long ll;
12 const int maxn=1005;
13 const int mod=26;
14 const int INF=0x3f3f3f3f;
15 const int Times = 10;
16 const int N = 5500;
17 ll gcd(ll a,ll b)
18 {
19 return b?gcd(b,a%b):a;
20 }
21 ll v[400005];
22 int main()
23 {
24 ll n;
25 scanf("%I64d",&n);
26 ll ans,v;
27 scanf("%I64d",&ans);
28 n--;
29 while(n--)
30 {
31 scanf("%I64d",&v);
32 ans=gcd(ans,v);
33 }
34 ll s=0;
35 for(ll i=1; i<=sqrt(ans); i++)
36 {
37 if(ans%i==0)
38 {
39 if(ans/i==i)
40 {
41 s--;
42 }
43 s+=2;
44 }
45 }
46 printf("%I64d\n",s);
47 return 0;
48 }
最新文章
- [原创]导出CSV文件,特殊字符处理。
- laravel打印sql语句
- paip.输入法编程--英文ati化By音标原理与中文atiEn处理流程 python 代码为例
- rwsr-sr-x类似权限设置
- 代码-Weka的NaiveBayes类
- 腾讯CDC谈扁平化设计
- MyBatis 通过包含的jdbcType类型和java中对应的数据类型
- docker 配置桥接网络
- POJ 2914 Minimum Cut 最小割图论
- error: C1083: 无法打开包括文件:“QDomDocument”“QAxObject”
- 转载 git Unknown SSL protocol error in connection to github.com:443
- Ubuntu安装Sublime Text3插件Emmet的依赖PyV8
- 一种使用 sprintf 导致死机的情况
- centos6.5安装Mysql5.6及更改密码
- (二)用控制器controller给模型数据赋初始值
- 【题目】求n以内的素数个数
- 防止DDoS攻击,每5分钟监控本机的web服务,将目前已经建立连接的IP计算出来,且实现top5。再此基础上,将并发连接超过50的IP禁止访问web服务
- oracle建表,设置主键,修改属性等
- Extjs 表单提交送给新手
- 判断ARP欺骗
热门文章
- stat filename
- SAP 技术设置(technical setting)
- Request&;Response总结
- Redis-第五章节-8种数据类型
- Py数据类型—整形与字符串
- 记一次ceph pg unfound处理过程
- Vue整合swiper报错Could not compile template .....swiper\dist\css\swiper.css解决办法
- Before you launch a goroutine, know when it will stop The Zen of Go
- int ping = 11; 限流 客户端验证与服务端是连接的
- 监听套接字描述字 已连接套接字描述字 和打电话的情形非常不一样的地方 完成了 TCP 三次握手,操作系统内核就为这个客户生成一个已连接套接字