# HDU Hdu Girls' Day

### Problem Description

Hdu Girls' Day is a traditional activity in Hdu. Girls in Hdu participate in the activity and show their talent and skill. The girls who win in the activity will become the Hdu's vivid ambassadors(形象大使). There are many students in Hdu concern the activity. Now it's the finally competition to determine who will be the Hdu's vivid ambassadors. The students vote for the girl they prefer. The girl who has the most number of votes will be the first. You as a student representing Hdu Acm team has a chance to vote. Every girl who participates in the activity has an unique No. and name. Because you very like prime number, you will vote for the girl whose No. has the maximum number of unique prime factors.

For example if the girl's No. is 12, and another girl's No. is 210, then you will choose the girl with No. 210. Because 210 = 2 *3 * 5*7 , 12 = 2*2*3. 210 have 4 unique prime factors but 12 just have 2. If there are many results, you will choose the one whose name has minimum lexicographic order.

### Input

The first line contain an integer T (1 <= T <= 100).Then T cases followed. Each case begins with an integer n (1 <= n <= 1000) which is the number of girls.And then followed n lines ,each line contain a string and an integer No.(1 <= No. <= 2^31 - 1). The string is the girl's name and No. is the girl's No.The string's length will not longer than 20.

### Output

For each case,output the girl's name who you will vote.

### Sample Input

2
3
Kate 56
Lily 45
Amanda 8
4
Sara 55
Ella 42
Cristina 210
Cozzi 2

### Sample Output

Kate
Cristina
#include<stdio.h>
#include<string.h>
#include<iostream>
#include<algorithm>
#include<math.h>
#include<queue>
#include<map>
using namespace std;
#define ll long long
const double Inf=1e+9;
/*思路很简单，就是先把素数表打出来，然后判断每个数字包含的素数个数，

*/
int prime[1000001]={0};
int main()
{
int i,j,t,n,m;
char name[100],s[100];  //一个存储，一个记录
for (i=2;i<1000;i++)
for (j=i*i;j<1000000;j+=i)
prime[j]=1;
scanf("%d",&t);
while (t--)
{
int Max=-1,k;
scanf("%d",&n);
while (n--)
{
k=0;
scanf("%s%d",name,&m);
for (i=2;i<=m;i++)
{
if (prime[i])
continue;
if (m%i==0)
{
k++;
m/=i;
}
}
if (k>Max)
{
Max=k;
strcpy(s,name);
}
else if (Max==k&&Max>0)
{
if (strcmp(s,name)>0)
strcpy(s,name);
}
}
printf("%s\n",s);
}
return 0;
}


• 本文已收录于以下专栏：

## hdu3294---Girls' research

Problem Description One day, sailormoon girls are so delighted that they intend to research about p...
• Guard_Mine
• 2015年02月18日 17:18
• 747

## hdu2574 Hdu Girls' Day

#include #include int main() {     int T,i,n,no,cnt,mCnt;     char name[21],mName[21];     sca...
• z245527922
• 2015年02月04日 20:57
• 322

## HDU 2574 Hdu Girls' Day

Problem Description Hdu Girls' Day is a traditional activity in Hdu. Girls in Hdu participate in ...
• u013776243
• 2014年04月05日 14:28
• 240

## HDU 2574 Hdu Girls' Day

• sky_miange
• 2015年04月20日 15:04
• 643

## Girls' research（hdu3294+Manacher算法）

Girls' research Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 65535/32768 K (Java/Others)...
• u010579068
• 2015年08月23日 16:09
• 1031

## HDU1068 Girls and Boys 【最大独立集】

#include #include #define maxn 1010 int n, A[maxn], B[maxn]; bool vis[maxn]; int head[maxn], id;...
• u012846486
• 2014年10月20日 07:36
• 1216

## hdu 5702 Solving Order（结构体排序 水题）

• qiqi_skystar
• 2016年07月01日 11:35
• 2657

## hdu 1068 Girls and Boys（匈牙利算法求最大独立集）

Girls and Boys Time Limit: 20000/10000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)...
• u011721440
• 2014年07月23日 20:46
• 959

## hdu 5145 NPY and girls（排列组合+莫队算法）

NPY and girls Time Limit: 8000/4000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) ...
• acm_cxq
• 2016年07月14日 19:06
• 301

## HDU 3294 Girls' research (Manacher算法 + 记录区间)

HDU 3294 Girls' research (Manacher算法 + 记录区间)
• Tc_To_Top
• 2015年02月14日 00:30
• 1119

举报原因： 您举报文章：HDU Hdu Girls' Day 色情 政治 抄袭 广告 招聘 骂人 其他 (最多只允许输入30个字)