-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy path10226.cpp
More file actions
68 lines (62 loc) · 803 Bytes
/
10226.cpp
File metadata and controls
68 lines (62 loc) · 803 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#include<iostream>
#include<stdio.h>
#include<map>
#include<string>
#include<string.h>
#include<algorithm>
using namespace std;
map<string,long>mp;
struct ss
{
long a;
string st;
}T[1000010];
bool cmp(ss aa,ss bb)
{
if(aa.st>bb.st)
return false;
else
return true;
}
char ch[1000010][40];
int main()
{
long t,i,j,k;
double cnt;
scanf("%ld",&t);
getchar();
getchar();
while(t--)
{
i=0;
while(gets(ch[i]))
{
if(strcmp(ch[i],"")==0)
break;
mp[ch[i]]++;
i++;
}
cnt=i;
k=0;
for(j=0;j<i;j++)
{
if(mp[ch[j]]!=0)
{
T[k].st=ch[j];
T[k].a=mp[ch[j]];
mp[ch[j]]=0;
k++;
}
}
sort(T,T+k,cmp);
for(i=0;i<k;i++)
{
cout<<T[i].st<<" ";
printf("%.4lf\n",(T[i].a/cnt)*100);
}
if(t)
printf("\n");
mp.clear();
}
return 0;
}