-
Notifications
You must be signed in to change notification settings - Fork 0
/
prob_10226.cpp
54 lines (50 loc) · 1.06 KB
/
prob_10226.cpp
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
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <map>
#include <cstring>
#include <vector>
#include <stack>
#include <queue>
#include <stdlib.h>
#include <string>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <climits>
#include <list>
#include <set>
#include <forward_list>
#define rep(i,a,b) for(i=a;i<b;++i)
#define vectIter(vect) for(auto &val: vect)
#define mapIter(map_) for(auto &val_: map_)
#define gc getchar_unlocked
using namespace std;
#define INF 999999999
struct functor{
bool operator()(const char* str1, const char* str2){
return strcmp(str1,str2)<0;
}
};
int main(){
int i,j,k,n;
map<char*,int,functor> database;
char str[35];
scanf("%d\n",&n);
while(n--){
while(fgets(str,34,stdin)!=NULL){
str[strlen(str)-1]='\0';
if(strlen(str)==0)
break;
++database[strdup(str)];
}
int count=0;
mapIter(database)
count+=val_.second;
mapIter(database)
printf("%s %.4f\n",val_.first,(double(val_.second)/count*100));
if(n)
cout << endl;
database.erase(database.begin(),database.end());
}
}