MiYu原创, 转帖请注明 : 转载自 ______________白白の屋  

因为 大于 1 << 16 的和数都能用 1 -- 1<<16 之间的素数表示, 不能表示的肯定是 素数了, 所以处理 1-- 1<<16之间的素数就可以了.

不过貌似这题的数据很弱没有大于 1 << 16 的素数.

代码

#include <iostream>
#include <algorithm>
#include <string>
#include <set>
#include <map>
#include <utility>
#include <queue>
#include <stack>
#include <vector>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
using namespace std;
struct type
{
char name[30];
int num;
}a[1005];
const int MAX_PRIME =  1 << 16;
# define PRIME_NUM 35000
int Primes[PRIME_NUM + 10] ;
bool  PrimeBuffer[MAX_PRIME];
int _Count = 0;
int GetPrimes ()
{
int i, j ;
for (i = 2 ; i < MAX_PRIME ; i++)
{
if (PrimeBuffer[i] == 0)
Primes[_Count++] = i ;
for (j = 0 ; j < _Count && i * Primes[j] <= MAX_PRIME ; j++)
{
PrimeBuffer[i * Primes[j]] = 1 ;
if (i % Primes[j] == 0) break ;
}
}
free (PrimeBuffer) ;
return _Count ;
}
inline bool scan_d(int &num)  //整数输入
{
char in;bool IsN=false;
in=getchar();
if(in==EOF) return false;
while(in!='-'&&(in<'0'||in>'9')) in=getchar();
if(in=='-'){ IsN=true;num=0;}
else num=in-'0';
while(in=getchar(),in>='0'&&in<='9'){
num*=10,num+=in-'0';
}
if(IsN) num=-num;
return true;
}
int main ()
{
int T;
GetPrimes ();
scan_d(T);
while ( T -- ) {
int N;
scan_d( N );
int ma = -1;
char mi[30] = "{";
for ( int i = 0 ; i < N ; ++ i ) {
scanf ( "%s",a[i].name);
scan_d( a[i].num );
int cnt = 0;
for ( int j = 0 ; j < _Count && a[i].num > 1 ; ++ j ) {
if ( a[i].num%Primes[j]==0 ) {
while(a[i].num%Primes[j]==0)
{
a[i].num /= Primes[j];
}
cnt++;      
}
}
if ( cnt == 0 ) cnt = 1;  // 没加这句也能A 说明没有 1 和 超过1<<16的素数
if ( ma < cnt ) { ma = cnt; strcpy ( mi, a[i].name ); }
else if ( ma == cnt ) { 
if ( strcmp ( a[i].name, mi ) < 0 )
strcpy ( mi, a[i].name );     
}
}
puts(mi);
}
return 0;
}

转载于:https://www.cnblogs.com/MiYu/archive/2010/11/16/1878824.html

HDU 2574 HDOJ 2574 Hdu Girls' Day ACM 2574 IN HDU相关推荐

  1. HDU 3082 HDOJ 3082 Simplify The Circuit ACM 3082 IN HDU

    MiYu原创, 转帖请注明 : 转载自 ______________白白の屋   题目地址 : http://acm.hdu.edu.cn/showproblem.php?pid=3082 题目分析: ...

  2. HDOJ 1157 HDU 1157 Who's in the Middle ACM 1157 IN HDU

    MiYu原创, 转帖请注明 : 转载自 ______________白白の屋   题目地址: http://acm.hdu.edu.cn/showproblem.php?pid=1157 题目描述: ...

  3. HDOJ HDU 2080 夹角有多大II ACM 2080 IN HDU

    MiYu原创, 转帖请注明 : 转载自 ______________白白の屋 题目地址:          http://acm.hdu.edu.cn/showproblem.php?pid=2080 ...

  4. HDOJ 2199 HDU 2199 Can you solve this equation? ACM 2199 IN HDU

    MiYu原创, 转帖请注明 : 转载自 ______________白白の屋 题目地址:          http://acm.hdu.edu.cn/showproblem.php?pid=2199 ...

  5. HDOJ 1874 HDU 1874 畅通工程续 ACM 1874 IN HDU

    MiYu原创, 转帖请注明 : 转载自 ______________白白の屋 题目地址:          http://acm.hdu.edu.cn/showproblem.php?pid=1874 ...

  6. HDOJ 1213 HDU 1213 How Many Tables ACM 1213 IN HDU

    MiYu原创, 转帖请注明 : 转载自 ______________白白の屋 题目地址:          http://acm.hdu.edu.cn/showproblem.php?pid=1213 ...

  7. HDOJ 1016 HDU 1016 Prime Ring Problem ACM 1016 IN HDU

    题目地址: http://acm.hdu.edu.cn/showproblem.php?pid=1016 题目描述: Prime Ring Problem Time Limit: 4000/2000 ...

  8. HDOJ 1253 HDU 1253 胜利大逃亡 ACM 1253 IN HDU

    MiYu原创, 转帖请注明 : 转载自 ______________白白の屋   题目地址: http://acm.hdu.edu.cn/showproblem.php?pid=1253 题目描述: ...

  9. HDOJ HDU 1106 排序 ACM 1106 IN HDU

    //MiYu原创, 转帖请注明 : 转载自 ______________白白の屋 题目地址 :             http://acm.hdu.edu.cn/showproblem.php?pi ...

最新文章

  1. 如何用eclipse操作MySQL数据库进行增删改查?
  2. 02 Scratch等级考试(二级)模拟题
  3. 移动端调用电话、短信、唤起QQ和使用百度地图
  4. 应用指定显示到副屏_彩易达LED显示屏在税务局的应用-彩易达,LED显示屏,在税务局的应用-LED屏行业...
  5. [Python人工智能] 二十七.基于BiLSTM-CRF的医学命名实体识别研究(下)模型构建
  6. ZZULIOJ 1108: 打印数字图形(函数专题)
  7. lua5.3 获取table的元素数量
  8. 【OpenCV】OpenCV实战从入门到精通之 -- 图像对比度、亮度值调整
  9. IOS AppUI规格指南
  10. 随想录(关于aarch64)
  11. CEPH RGW集群和bucket的zone group 不一致导致的404异常解决 及 使用radosgw-admin metadata 命令设置bucket metadata 的方法
  12. 升级AndrOid4.3,谷歌发布Android 4.3系统 今日开始升级
  13. python 折线图拐角平滑_python利用插值法对折线进行平滑曲线处理
  14. 【openwrt】使用4G模块 移远EC20/25(1)内核配置
  15. 问题解决:无法解析的外部符号 _imp_XXXXXXXXX
  16. Arduino上U8g2库自定义中文库的经历
  17. FileNotFoundException: http:\localhos46087125.jpg (文件名、目录名或卷标语法不正确
  18. PWM的周期和占空比是如何计算
  19. 人工智能大战苹果缺席 保护用户隐私拖慢其步伐
  20. 哪个学校计算机在职研究生有双证,计算机专业在职研究生如何获得双证?

热门文章

  1. 比navicat更好用的工具_5118是查什么的?做什么用的?对比站长工具和爱站谁更好?...
  2. android 文字fly动画,超好看的下拉刷新动画Android代码实现
  3. python里的符号区别_Python中的方括号和点符号有什么区别?
  4. suse linux下交叉编译,阐述SUSE 10.1交叉编译环境构建方法
  5. 搭载鸿蒙os的电脑,全新华为 MatePad Pro 发布在即:搭载鸿蒙系统
  6. 蓝牙:为啥叫“蓝”牙,不叫“白”牙?
  7. 这种制作PCB板的方法,只需要一分钟!
  8. 《FPGA入门教程》看书随笔——RTL设计
  9. Linux复位usb hub,Linux USB subsystem --- USB Hub initialize
  10. 按值传递时 php必须复制值,PHP笔试题汇总