题意:判断一些数里有最大因子的数

水题,省赛即将临近,高效的代码风格需要养成,为了简化代码,以后可能会更多的使用宏定义,但是通常也只是快速拿下第一道水题,涨自信。大部分的代码还是普通的形式,实际上能简化的部分也不太多

 #include<iostream>
#include<cstring>
#include<cmath>
#include<cstdio>
using namespace std;
#define for0n for(i=0;i<n;i++)
#define for1n for(i=1;i<=n;i++)
const int MAXN=;
int prime[MAXN+];
void getPrime()
{
memset(prime,,sizeof(prime));
for(int i=;i<=MAXN;i++)
{
if(!prime[i])prime[++prime[]]=i;
for(int j=;j<=prime[]&&prime[j]<=MAXN/i;j++)
{
prime[prime[j]*i]=;
if(i%prime[j]==) break;
}
}
}
long long factor[][];
int fatCnt;
int getFactors(long long x)
{
fatCnt=;
long long tmp=x;
for(int i=;prime[i]<=tmp/prime[i];i++)
{
factor[fatCnt][]=;
if(tmp%prime[i]==)
{
factor[fatCnt][]=prime[i];
while(tmp%prime[i]==)
{
factor[fatCnt][]++;
tmp/=prime[i];
}
fatCnt++;
}
}
if(tmp!=)
{
factor[fatCnt][]=tmp;
factor[fatCnt++][]=;
}
return fatCnt;
} int main()
{
#ifndef ONLINE_JUDGE
freopen("1.in","r",stdin);
#endif
int t,n,k;
int i,j;
getPrime();
int flag;
while(cin>>n)
{
int maxx=-;
for0n
{
cin>>k;
getFactors(k);
if(maxx<factor[fatCnt-][])
{
flag=k;
maxx=factor[fatCnt-][];
}
}
cout<<flag<<endl;
}
}

hdu 2710 水题的更多相关文章

  1. HDU-1042-N!(Java大法好 &amp;&amp; HDU大数水题)

    N! Time Limit: 10000/5000 MS (Java/Others)    Memory Limit: 262144/262144 K (Java/Others) Total Subm ...

  2. HDU 5391 水题。

    E - 5 Time Limit:1500MS     Memory Limit:262144KB     64bit IO Format:%I64d & %I64u Submit Statu ...

  3. hdu 1544 水题

    水题 /* * Author : ben */ #include <cstdio> #include <cstdlib> #include <cstring> #i ...

  4. HDU排序水题

    1040水题; These days, I am thinking about a question, how can I get a problem as easy as A+B? It is fa ...

  5. Dijkstra算法---HDU 2544 水题(模板)

    /* 对于只会弗洛伊德的我,迪杰斯特拉有点不是很理解,后来发现这主要用于单源最短路,稍稍明白了点,不过还是很菜,这里只是用了邻接矩阵 套模板,对于邻接表暂时还,,,没做题,后续再更新.现将这题贴上,应 ...

  6. hdu 5162(水题)

    题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5162 题解:看了半天以为测试用例写错了.这题玩文字游戏.它问的是当前第i名是原数组中的第几个. #i ...

  7. hdu 3357 水题

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=3357 #include <cstdio> #include <cmath> # ...

  8. hdu 5038 水题 可是题意坑

    http://acm.hdu.edu.cn/showproblem.php?pid=5038 就是求个众数  这个范围小 所以一个数组存是否存在的状态即可了 可是这句话真恶心  If not all ...

  9. hdu 5138(水题)

    题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5138 反着来. #include<iostream> #include<cstdi ...

随机推荐

  1. linux服务器安装mysql并配置外网访问

    linux服务器安装mysql并配置外网访问 更新系统,如果不运行该命令,直接安装mysql,会出现"有几个软件包无法下载 sudo apt-get update 安装mysql sudo ...

  2. 如何修改Linux的TTL值

    原文地址:http://www.linuxidc.com/Linux/2011-11/47701.htm 网络黑客如果用ping命令去探测  一个主机,根据TTL基数可以推测操作系统的类型.对于一个没 ...

  3. Github 开源项目(二) jsmpeg-vnc

    参考文章:http://blog.csdn.net/qq_28877125/article/details/70141713 适用于Windows的低延迟,高帧率屏幕共享服务器以及用于浏览器的客户端 ...

  4. 洛谷 P1056 排座椅 桶排序

    桶排序大法好! 每次一看到这种范围小的题,本萌新就想用桶排. 因为题目中的m,n都小于1000,我们就可以定义两个1000的数组,表示每一行或每一列可以隔开几对讲话的童鞋. 然后再定义两个1000的数 ...

  5. Opencv学习笔记——release和debug两个模式的运行问题

    本文为原创作品,转载请注明出处 欢迎关注我的博客:http://blog.csdn.net/hit2015spring和http://www.cnblogs.com/xujianqing/ 作者:晨凫 ...

  6. 微信小程序调用接口返回数据或提交数据

    由于小程序发起网络请求需要通过 wx.request 文档地址 https://mp.weixin.qq.com/debug/wxadoc/dev/api/network-request.html 习 ...

  7. 安装Python3.6.4后,在使用numpy时报错RuntimeWarning: numpy.dtype size changed, may indicate binary incompatibility. Expected 96, got 88

    原因: 因为安装numpy用的是 pip来安装的 pypi官方对于numpy的库已经升级了,但是升级后的版本与其他的库不匹配 所以报错 解决: 先把已经安装的numpy卸载: pip uninstal ...

  8. Kali Linux没有声音的解决方法

    Kali Linux系统默认状态下,root用户是无法使用声卡的,也就没有声音.启用的方法如下:         (1)在终端执行命令:systemctl --user enable pulseaud ...

  9. js各种小知识

    1.获取函数里面的参数个数 function test(x,y,z){} // 获取test参数的个数 console.log(test.length)

  10. MCS-51 单片机的中断系统

    MCS-51 单片机的中断系统 MCS-51中断系统:5个中断源(两个外部中断, 两个定时器, 一个串口),2个优先级 中断相关概念 中断:当CPU正在处理某件事情时,单片机外部或内部发生的某一紧急事 ...