Codeforces 757B - Bash's Big Day(分解因子+hashing)

时间:2021-12-14 08:10:17

757B - Bash's Big Day

思路:筛法。将所有因子个数求出,答案就是最大的因子个数,注意全为1的特殊情况。

代码:

#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
const int N=1e5+;
int vis[N]={};
int main()
{
ios::sync_with_stdio(false);
cin.tie();
int n,a;
cin>>n;
for(int i=;i<n;i++)
{
cin>>a;
for(int j=;j*j<=a;j++)
{
if(a%j==)
{
vis[j]++;
if(j*j!=a)vis[a/j]++;
}
}
}
int ans=;
for(int i=;i<N;i++)ans=max(ans,vis[i]);
cout<<ans<<endl;
return ;
}

Codeforces 757B - Bash's Big Day(分解因子+hashing)的更多相关文章

  1. Codeforces 757B&period; Bash&&num;39&semi;s Big Day GCD

    B. Bash's Big Day time limit per test:2 seconds memory limit per test:512 megabytes input:standard i ...

  2. Codeforces 1058 D&period; Vasya and Triangle 分解因子

    传送门:http://codeforces.com/contest/1058/problem/D 题意: 在一个n*m的格点中,问能否找到三个点,使得这三个点围成的三角形面积是矩形的1/k. 思路: ...

  3. uva 993 Product of digits &lpar;贪心 &plus; 分解因子&rpar;

      Product of digits  For a given non-negative integer number N , find the minimal natural Q such tha ...

  4. D&period; Almost All Divisors&lpar;数学分解因子&rpar;

    其实这题并不难啊,但是分解因子的细节一定要小心. \(比如样例48,2是因子说明24也是因子,也就是说假如x存在\) \(那么x一定是因子中的最小数乘上最大数\) \(那我们现在去验证x是否存在,先拿 ...

  5. Codeforces 757B:Bash&&num;39&semi;s Big Day(分解因子&plus;Hash)

    http://codeforces.com/problemset/problem/757/B 题意:给出n个数,求一个最大的集合并且这个集合中的元素gcd的结果不等于1. 思路:一开始把素数表打出来, ...

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

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

  7. Codeforces 1058 D&period; Vasya and Triangle(分解因子)

    题目:http://codeforces.com/contest/1058/problem/D 题意:有一个大小为N*M的矩阵内,构造一个三角形,使面积为(n*m)/k.若存在输出三个顶点(整数). ...

  8. 【Codeforces 757B】 Bash&&num;39&semi;s big day

    [题目链接] 点击打开链接 [算法] 若gcd(s1,s2,s3....sk) > 1, 则说明 : 一定存在一个整数d满足d|s1,d|s2,d|s3....,d|sk 因为我们要使|s|尽可 ...

  9. Codeforces E&period; Bash Plays with Functions&lpar;积性函数DP&rpar;

    链接 codeforces 题解 结论:\(f_0(n)=2^{n的质因子个数}\)= 根据性质可知\(f_0()\)是一个积性函数 对于\(f_{r+1}()\)化一下式子 对于 \[f_{r+1} ...

随机推荐

  1. keil MDK error&colon; L6236E&colon; No section matches selector - no section 错误

    今天板子刚到,新建的第一个工程就报错了. .\Objects\cse.sct(7): error: L6236E: No section matches selector - no section t ...

  2. IDEA集成MAVEN 报错

      解决-Dmaven.multiModuleProjectDirectory system property is not set. Check $M2_HOME environment varia ...

  3. C&plus;&plus;里的静态成员函数不能用const的原因

    From http://blog.csdn.net/freeboy1015/article/details/7634950     static在c++中的第五种含义:用static修饰不访问非静态数 ...

  4. shell 判断字符串是否为数字

    本篇文章主要介绍了"shell 判断字符串是否为数字",主要涉及到shell 判断字符串是否为数字方面的内容,对于shell 判断字符串是否为数字感兴趣的同学可以参考一下. #!/ ...

  5. 由Tencent&colon;&sol;&sol;Message协议想到的一个解决方案

    参考网址:http://www.cnblogs.com/phinecos/archive/2009/03/06/1404951.html 源代码下载:http://files.cnblogs.com/ ...

  6. Spring连接数据库的几种常用的方式

    本文简单的讲解使用Spring连接数据库的几种常用方法: 测试主类为: package myspring2; import java.sql.*; import javax.sql.DataSourc ...

  7. localStorage点击次数存储

    <!DOCTYPE html><html><head><meta charset="utf-8"> <title>菜鸟教 ...

  8. 汇总jQuery的61种选择器及示例

    汇总jQuery的61种选择器及示例 恋痿喃 ㄍń稀广 因罘乐睽 ú燔蒇 骤幄觳 ч豹 齑骝氮铷 宅廓Ω孓 锏遒 荛猩ㄜ彬 芡钷ж ┊贩错鹌 掩饰着可还是几步就窜到了门口看着这个让她 ...

  9. tp 框架的增

    //增 public function test() { //数据访问 //造模型对象 $nation = D("Nation"); $,'页面跳转中请稍后....'); } pu ...

  10. cygwin 下安装python MySQLdb

    cygwin 下安装python MySQLdb 1) cygwin 更新 运行 cygwin/setup-x86_64.exe a 输入mysql,选择下面的包安装: libmysqlclient- ...