Common Divisors CodeForces - 1203C
题意:
给你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 }
Common Divisors CodeForces - 1203C的更多相关文章
- Common Divisors CodeForces - 182D || kmp最小循环节
Common Divisors CodeForces - 182D 思路:用kmp求next数组的方法求出两个字符串的最小循环节长度(http://blog.csdn.net/acraz/articl ...
- B - Common Divisors (codeforces)数论算法基本定理,唯一分解定理模板
You are given an array aa consisting of nn integers. Your task is to say the number of such positive ...
- [gcd]Codeforces Common Divisors
Common Divisors time limit per test 2 seconds memory limit per test 256 megabytes input standard inp ...
- Codeforces Round #579 (Div. 3) B Equal Rectangles、C. Common Divisors
B Equal Rectangles 题意: 给你4*n个数,让你判断能不能用这个4*n个数为边凑成n个矩形,使的每个矩形面积相等 题解: 原本是想着用二分来找出来那个最终的面积,但是仔细想一想,那个 ...
- CF #579 (Div. 3) C.Common Divisors
C.Common Divisors time limit per test2 seconds memory limit per test256 megabytes inputstandard inpu ...
- Codeforces Round #117 (Div. 2) D.Common Divisors(KMP最小循环节)
http://codeforces.com/problemset/problem/182/D 题意:如果把字符串a重复m次可以得到字符串b,那么我们称字符串a为字符串b的一个因子,现在给定两个字符串S ...
- Mishka and Divisors[CodeForces Round #365 Div.2]
http://codeforces.com/contest/703/problem/E 题意:给定一个最多个数的序列,从中选出最少个数的数字,使得他们的乘积是k的倍数,若有多种选择方式,输出选出数字和 ...
- <Sicily>Greatest Common Divisors
一.题目描述 A common divisor for two positive numbers is a number which both numbers are divisible by. It ...
- Codeforces182D - Common Divisors(KMP)
题目大意 如果把字符串a重复m次可以得到字符串b,那么我们称字符串a为字符串b的一个因子,现在给定两个字符串S1和S2,求它们的公共因子个数 题解 如果它们有公共因子,那么显然它们的最小公共因子肯定是 ...
随机推荐
- 浅谈sql索引
索引是什么 假如你手上有一个你公司的客户表,老板说找什么客户你就得帮他找出来. 客户不多的时候,你拿着手指一行一行滑,费不了多少时间就能找到. 后来公司做大了,客户越来越多,好几页的客户,你发现,一行 ...
- mybatis入门教程之搭建一个简单的mybatis项目并启动它
一.准备条件: 1.依赖jar包:mybatis核心包(必须).lombok插件包(非必须)以及MySQL数据库连接驱动包(必须) <dependency> <groupId> ...
- 【Oracle LISTNER】oracle Listener 宕机解决办法
今天想起了很久没用的oracle库,用plsql尝试连接,发现报超时错误,以为是偶然,多次尝试连接,发现还是超时,于是登录到系统中,查看数据库情况,发现正常查询和修改添加,感觉不是数据库问题,查看监听 ...
- 如何在windows开机画面里隐藏用户
当开机的时候都会在欢迎屏幕中显示一个账户或者多个已经建立的账户,通常还会显示登录的用户名,我们可以通过修改注册表实现把某个用户隐藏,具体方法如下:http://hi.baidu.com/liminsu ...
- SAP 摘录数据集
要在报表中创建并填充摘录数据集,需要执行三步骤:1.将要在摘录数据集中使用的记录类型定义为字段组FIELD-GROUPS该语句定义了字段组,字段组可以将几个字段组合到一个名称下,字段组不为字段保留存储 ...
- 镍氢可充电电池2.4V转3.3V,2V转3.3V稳压供电输出电路图
PW5100可以实现2.4V转3.3V,2V转3.3V的稳压电源电路,输出电流500MA.静态电流10uA,SOT23-5封装.输出纹波低,轻载性能高(轻载电感推荐6.8UH-10UH). PW510 ...
- 1.2V转3.3V芯片电路图,超简电路
镍氢可充电电池1.2V转成3.3V的电路和电子产品很多,在实际适用中,即使是两节镍氢电池串联供电也是会有供电电压下降和不稳定的影响,这是因为电池电量减少,而导致电池的电压也是会随着降低. 一般情况下, ...
- PC端微信多开方式.bat(Windows批处理文件)
start 微信安装路径\WeChat.exe start 微信安装路径\WeChat.exe
- ShardingSphere内核原理 原创 鸽子 架构漫谈 2021-01-09
ShardingSphere内核原理 原创 鸽子 架构漫谈 2021-01-09
- What is the difference between Serialization and Marshaling?
How to serialize and deserialize JSON using C# - .NET | Microsoft Docs https://docs.microsoft.com/en ...