mhdew

Contest 4_H

Feb 15th, 2018
217
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.91 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2.  
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7. //freopen("In.txt", "r", stdin);
  8. //freopen("Out.txt", "w", stdout);
  9.  
  10. map<string,int>mp;
  11. vector<string>vec;
  12. int x;
  13. int i, n;
  14. double tree;
  15. char a[100];
  16. double ans;
  17. int cunt;
  18.  
  19. scanf("%d", &n);
  20. getchar();
  21. getchar();
  22. for(i=1;i<=n;i++){
  23. cunt=0;
  24. for(;;){
  25. gets(a);
  26. if(strlen(a)==0)
  27. break;
  28. cunt++;
  29. if(mp[a]==0)
  30. vec.push_back(a);
  31. mp[a]++;
  32. }
  33. stable_sort(vec.begin(),vec.end());
  34.  
  35. tree=vec.size();
  36. for(int j=0;j<vec.size();j++){
  37. ans=(mp[vec[j]])*100/(cunt*1.0);
  38. cout<<vec[j]<<" ";
  39. printf("%.4lf\n", ans);
  40. }
  41. if(i!=n)
  42. printf("\n");
  43. }
  44. return 0;
  45. }
Advertisement
Add Comment
Please, Sign In to add comment