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. Bash'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. Vasya and Triangle 分解因子

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

  3. uva 993 Product of digits (贪心 + 分解因子)

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

  4. D. Almost All Divisors(数学分解因子)

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

  5. Codeforces 757B:Bash's Big Day(分解因子+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. Vasya and Triangle(分解因子)

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

  8. 【Codeforces 757B】 Bash's big day

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

  9. Codeforces E. Bash Plays with Functions(积性函数DP)

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

随机推荐

  1. linux中的各种$号 位置参数变量

    位置参数变量   $n   #/bin/bash echo $0(代表命令本身); echo $1; (代表第几个参数) echo $2;   [root@LocalWeb01 ~]# ./1.sh ...

  2. System.arraycopy方法详解

  3. CTC(Connectionist Temporal Classification)介绍

    CTC解决什么问题 CTC,Connectionist Temporal Classification,用来解决输入序列和输出序列难以一一对应的问题. 举例来说,在语音识别中,我们希望音频中的音素和翻 ...

  4. python 爬虫煎蛋网

    import urllib.request import os from urllib import error import re import base64 def url_open(url): ...

  5. python练习-生成一个1到50的大字符串每个数字之间有个空格

    #-*-encoding:UTF-8-*- string=[] for i in range(1,51): string.append(str(i)) print string#打印一下string ...

  6. 人工智能范畴及深度学习主流框架,谷歌 TensorFlow,IBM Watson认知计算领域IntelligentBehavior介绍

    人工智能范畴及深度学习主流框架,谷歌 TensorFlow,IBM Watson认知计算领域IntelligentBehavior介绍 ================================ ...

  7. php new stdClass array 实例代码

    php new stdClass array 实例代码 $searchResults = array ();// //$obj = array ("rs"=>array(), ...

  8. Oracle提示错误消息ORA-28001: the password has expired

    首先,以SYS DBA身份进入sqlpuls 打开sqlpuls SQL->请输入用户名:sys as sysdba SQL->密码: 登录成功以后查询DBA用户状态 SQL->se ...

  9. Notes of Head.First.HTML.and.CSS.2nd.Edition

    What does the web server do? tirelessly waiting for requests from webbrowsers What does the web brow ...

  10. 20145334赵文豪《网络对抗》-逆向及Bof基础实践

    本次实践的对象是一个名为pwn1的linux可执行文件. 该程序正常执行流程是:main调用foo函数,foo函数会简单回显任何用户输入的字符串. 该程序同时包含另一个代码片段,getShell,会返 ...