hdu_2574 Hdu Girls' Day
来源:互联网 发布:淘宝如何完成实名认证 编辑:程序博客网 时间:2024/06/05 19:02
Hdu Girls' Day
2014-8-1 20:23
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.
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
23Kate 56Lily 45Amanda 84Sara 55Ella 42Cristina 210Cozzi 2
Sample Output
KateCristina
#include<stdio.h>#include<string.h>#define maxn 1000000int a[maxn]={0,0};void count(){ for(int i=2;i*i<maxn;i++) { if(!a[i]) { for(int j=i*i;j<maxn;j+=i) a[j]=1; } }}int main(){ count(); int T,num,k,shu,max,n,q; char name[22],s[22]; scanf("%d",&T); while(T--) { max=-1; scanf("%d",&n); while(n--) { shu=0;q=0; scanf("%s%d",&name,&num); for(k=2;k<=num;k++) { if(a[k]) continue; else { if(num%k==0) { if(k!=q) shu++; q=k; num=num/k; } } } if(shu>max) { max=shu; strcpy(s,name); } else if(max==shu) { if(strcmp(name,s)<0) //name是当前的,s是之前存的,若当前的更小,就把当前的存入s strcpy(s,name); } } printf("%s\n",s); } return 0;}
0 0
- hdu_2574 Hdu Girls' Day
- HDU Hdu Girls' Day
- hdu2574 Hdu Girls' Day
- HDU 2574 Hdu Girls' Day
- HDU 2574 Hdu Girls' Day
- Girls' Day
- hdu 2574 Hdu Girls' Day (质因子的个数)
- poj1677-Girls' Day
- POJ 1677 Girls' Day
- POJ 1677 Girls' Day 笔记
- hdu 3294 Girls' research
- hdu 3294 Girls' research
- HDU 3294 Girls' research
- hdu 3294 Girls' research
- HDU 3294Girls' research
- Girls and Boys HDU
- hdu 2690 Boys and girls
- HDU-1068 Girls and Boys
- 老鼠试毒算法
- HDU 4864 Task(贪心,输出利润的最大值)
- UVA10148- Advertisement(区间选点)
- 在本机使用不同版本VS编译boost
- hdu-1203-I NEED A OFFER!
- hdu_2574 Hdu Girls' Day
- 填数问题
- jsp企业设备管理系统
- python+PyQT+Eric安装配置
- 存储过程---留住你的美丽(下)
- HDU 2042 不容易系列之二【简单递推】
- HDU-1176 免费馅饼
- 图像处理与计算机视觉基础,经典以及最近发展
- java中方法的重载和方法的覆写的区别