HDU 2574 Hdu Girls' Day



Hdu Girls‘ Day

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)

Total Submission(s): 1575    Accepted Submission(s): 468

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

Source

HDU 2009-5 Programming Contest

求出所有素因子然后排个序就好。。

#include <cstdio>
#include <algorithm>
#include <map>
#include <cstring>
#include <cmath>
#include <iostream>
using namespace std;
#define lson l , m , rt << 1
#define rson m + 1 , r , rt << 1 | 1
#define LL __int64
#define PI 3.1415926
const int maxn = 1000000;
int a[maxn];
struct node
{
    char name[2222];
    int score;
    int sum;
};
node f[1005];
bool cmp(node aa,node bb)
{
    if(aa.sum==bb.sum)
        return strcmp(aa.name,bb.name)<0;
    else
        return aa.sum>bb.sum;
}
int main()
{

    int t,ans;
    cin>>t;
    while(t--)
    {
        int n;
        cin>>n;
        int i,j;
        int max;
        max=-1;
        for(i=0; i<n; i++)
        {
            ans=0;
            cin>>f[i].name>>f[i].score;
            for(j=2; j*j<=f[i].score; j++)
            {
                if(f[i].score&&f[i].score%j==0)
                {
                    ans++;
                    while(f[i].score&&f[i].score%j==0)
                        f[i].score/=j;
                }
            }
            if(f[i].score>1)
                ans++;
            f[i].sum=ans;
        }
        sort(f,f+n,cmp);
        cout<<f[0].name<<endl;
    }
    return 0;
}

HDU 2574 Hdu Girls' Day

时间: 2024-10-08 01:00:12

HDU 2574 Hdu Girls' Day的相关文章

HDU 3294 (Manacher) Girls&#39; research

变形的求最大回文子串,要求输出两个端点. 我觉得把'b'定义为真正的'a'是件很无聊的事,因为这并不会影响到最大回文子串的长度和位置,只是在输出的时候设置了一些不必要的障碍. 另外要注意一下原字符串s1中的字符在预处理以后的字符串s2中对应的坐标关系,这样输出的时候就可以照着这个关系转化. 轻松1A,嘿嘿 1 //#define LOCAL 2 #include <iostream> 3 #include <cstdio> 4 #include <cstring> 5

hdu 3061 hdu 3996 最大权闭合图 最后一斩

hdu 3061 Battle :一看就是明显的最大权闭合图了,水提......SB题也不说边数多少....因为开始时候数组开小了,WA....后来一气之下,开到100W,A了.. hdu3996.  gold mine..看了一下,简单题,几乎裸,不敲了.. #include<iostream>//Battle #include<queue> #include<cstdio> #include<cstring> #include<set> #i

hdu 3081 hdu 3277 hdu 3416 Marriage Match II III IV //最大流的灵活运用

3081 题意: n个女孩选择没有与自己吵过架的男孩有连边(自己的朋友也算,并查集处理),2分图,有些边,求有几种完美匹配(每次匹配每个点都不重复匹配) 我是建二分图后,每次增广一单位,(一次完美匹配),再修改起点还有终点的边流量,继续增广,直到达不到完美匹配为止.网上很多是用二分做的,我觉得没必要...(网上传播跟风真严重...很多人都不是真正懂最大流算法的...) 3277 : 再附加一条件,每个女孩可以最多与k个自己不喜欢的男孩.求有几种完美匹配(同上). 我觉得:求出上题答案,直接ans

2014多校联合六(HDU 4923 HDU 4925 HDU 4927 HDU 4930)

HDU 4923 Room and Moor 题意:给出A序列  求满足题目所写的B序列  使得方差最小 思路:可以想到最后的结果中  B序列的值一定是一段一段的  那么我们可以类似贪心去搞  对于一段序列我们可以求出什么样的b值使得方差最小  即序列中1的个数除以序列长度  又因为B是单调的  可以用一个单调栈去模拟  复杂度远远小于n^2  不要被吓怕- 代码: #include<cstdio> #include<cstring> #include<algorithm&g

2014多校联合三 (HDU 4888 HDU 4891 HDU 4893)

HDU 4891 The Great Pan 签到题  他怎么说你就怎么做就好了  注意做乘法时候会爆int 代码: #include<iostream> #include<cstdio> #include<cstring> #include<algorithm> using namespace std; typedef long long LL; int n; char s[2000000]; int flag1, flag2, sp, ansflag;

SG 函数初步 HDU 1536 &amp;&amp; HDU 1944

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1944 http://acm.hdu.edu.cn/showproblem.php?pid=1536 给定每一次可以取的石头数,给定很多种情况,每一种情况有若干堆石头,判断先手胜负. SG函数打表,然后直接抑或,判断结果是否为0,第一次写SG函数,贴个代码,慢慢理解. 代码: /* *********************************************** Author :rabb

hdu 3879 hdu 3917 构造最大权闭合图 俩经典题

hdu3879  base station : 各一个无向图,点的权是负的,边的权是正的.自己建一个子图,使得获利最大. 一看,就感觉按最大密度子图的构想:选了边那么连接的俩端点必需选,于是就以边做点,轻轻松松构造了最大权闭合图.简单题.分分钟搞定. hdu3917 :road  constructions :这题题目看了半天没理解...感觉描述的不好...一个有向图,每条路有响应公司承保,若选了该公司,那么该公司的路必需全部选,还有,该公司的承保的路的下面的一条路对应公司也要选,求最大获利.构

2014多校联合五(HDU 4911 HDU 4915 HDU 4920)

HDU 4911 Inversion 题意:n个数字  通过k次相邻交换  使得逆序对数最少 思路:如果序列为 XXXABYYY  假设A和B位置互换  易知X和AB.Y和AB的逆序对数不变  换句话说一次交换最多使逆序对减少1  那么只需要求原逆序对数和k进行比较即可 代码: #include<cstdio> #include<cstring> #include<algorithm> using namespace std; #define N 100100 type

HDU 1003 &amp;&amp; HDU 1081(最大子列和,最大子矩阵和).

最大子列和,及其扩展最大子矩阵和,都是比较经典的dp,把这两题写在一起,共大家参考学习. ~~~~ lz弱菜啊,到现在还只能写这么水的DP...orz. ~~~~ 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1003 http://acm.hdu.edu.cn/showproblem.php?pid=1081 题意应该比较好理解,不解释了. 1003: #include<cstdio> #include<iostream> #inc