【题目链接】

点击打开链接

【算法】

若gcd(s1,s2,s3....sk) > 1,

则说明 : 一定存在一个整数d满足d|s1,d|s2,d|s3....,d|sk

因为我们要使|s|尽可能大,所以d是一个质数

对每个数进行质因数分解即可

【代码】

#include<bits/stdc++.h>
using namespace std;
const int MAXN = 1e5; int N,i,j,tmp,ans;
int a[MAXN+],s[MAXN+]={,}; template <typename T> inline void read(T &x) {
int f = ; x = ;
char c = getchar();
for (; !isdigit(c); c = getchar()) { if (c == '-') f = -f; }
for (; isdigit(c); c = getchar()) x = x * + c - '';
x *= f;
} template <typename T> inline void write(T x) {
if (x < ) { putchar('-'); x = -x; }
if (x > ) write(x/);
putchar(x%+'');
} template <typename T> inline void writeln(T x) {
write(x);
puts("");
} int main() { read(N);
for (i = ; i <= N; i++) read(a[i]);
for (i = ; i <= N; i++) {
tmp = a[i];
for (j = ; j <= sqrt(tmp); j++) {
if (!(tmp % j)) ++s[j];
while (!(tmp % j)) tmp /= j;
}
if (tmp > ) ++s[tmp];
}
for (i = ; i <= MAXN; i++) ans = max(ans,s[i]);
writeln(ans); return ; }

【Codeforces 757B】 Bash's big day的更多相关文章

  1. 【codeforces 757B】 Bash's Big Day

    time limit per test2 seconds memory limit per test512 megabytes inputstandard input outputstandard o ...

  2. 【codeforces 757E】Bash Plays with Functions

    [题目链接]:http://codeforces.com/problemset/problem/757/E [题意] 给你q个询问; 每个询问包含r和n; 让你输出f[r][n]; 这里f[0][n] ...

  3. 【codeforces 415D】Mashmokh and ACM(普通dp)

    [codeforces 415D]Mashmokh and ACM 题意:美丽数列定义:对于数列中的每一个i都满足:arr[i+1]%arr[i]==0 输入n,k(1<=n,k<=200 ...

  4. 【codeforces 757A】Gotta Catch Em' All!

    time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard ou ...

  5. 【codeforces 707E】Garlands

    [题目链接]:http://codeforces.com/contest/707/problem/E [题意] 给你一个n*m的方阵; 里面有k个联通块; 这k个联通块,每个连通块里面都是灯; 给你q ...

  6. 【codeforces 707C】Pythagorean Triples

    [题目链接]:http://codeforces.com/contest/707/problem/C [题意] 给你一个数字n; 问你这个数字是不是某个三角形的一条边; 如果是让你输出另外两条边的大小 ...

  7. 【codeforces 709D】Recover the String

    [题目链接]:http://codeforces.com/problemset/problem/709/D [题意] 给你一个序列; 给出01子列和10子列和00子列以及11子列的个数; 然后让你输出 ...

  8. 【codeforces 709B】Checkpoints

    [题目链接]:http://codeforces.com/contest/709/problem/B [题意] 让你从起点开始走过n-1个点(至少n-1个) 问你最少走多远; [题解] 肯定不多走啊; ...

  9. 【codeforces 709C】Letters Cyclic Shift

    [题目链接]:http://codeforces.com/contest/709/problem/C [题意] 让你改变一个字符串的子集(连续的一段); ->这一段的每个字符的字母都变成之前的一 ...

随机推荐

  1. 顿悟:Linux是拿来用的,不是拿来折腾的

    Linux是拿来用的,而不是折腾其本身.相信这个道理不少聪明人(实用主义者)都明白,然而总是有那么一群人拿Linux去安装各种发行版.研究Linux命令.配置桌面.美化桌面.研究各种wm/DE.永无止 ...

  2. Unity3D 异步加载 在 场景加载 中的使用

    异步加载 我们想一想玩过的一些游戏,基本都会有加载界面——因为游戏场景数据较大,所以需要加载一小段时间.那为什么一些2D游戏也会有加载界面呢?按理说2D游戏场景会很小,这样做是为了让游戏跑在低端设备上 ...

  3. python3.x之print()

    1.print内容 #!/usr/bin/python print('hello world')    //print("hello world") 2.print变量 #!/us ...

  4. Codeforces 959 E Mahmoud and Ehab and the xor-MST

    Discription Ehab is interested in the bitwise-xor operation and the special graphs. Mahmoud gave him ...

  5. Java面试题集(151-180)

    摘要:这部分包括了Spring.Spring MVC以及Spring和其它框架整合以及測试相关的内容,除此之外还包括了大型站点技术架构相关面试内容. 151. Spring中的BeanFactory和 ...

  6. C#对二进制文件的特定位置进行读写小结

    虽然网络上关于“C#对二进制文件进行读写”的文章多如牛毛,但具体到自己要处理的问题时,难免让人产生“书到用时方恨少”和“纸上读来终觉浅”的感觉.我现在感觉要真正解决自己的问题,最终还是要靠自己下功夫. ...

  7. C++模板实现的AVL树

    1 AVL树的定义 AVL树是一种自平衡二叉排序树.它的特点是不论什么一个节点的左子树高度和右子树的高度差在-1,0,1三者之间. AVL树的不论什么一个子树都是AVL树. 2 AVL树的实现 AVL ...

  8. Vue 建立工程

    npm install -g vue npm install -g vue-cli vue init webpack my-project cd my-project npm isntall npm ...

  9. CustomView

    https://github.com/eltld/CustomView

  10. 解压Zip

    import java.io.BufferedOutputStream; import java.io.File; import java.io.FileOutputStream; import ja ...