Advertisement
Saleh127

UVA 10226

Dec 10th, 2020
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.03 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. #define ll long long
  4. int main()
  5. {
  6.  
  7. int t;
  8. scanf("%d", &t);
  9. getchar();
  10.  
  11. for(int i=1; i<=t; i++)
  12. {
  13. string s;
  14. if(i==1)getline(cin, s);
  15.  
  16. map<string, int> a;
  17. map<string, int>::iterator it;
  18.  
  19. int n=0;
  20.  
  21. while(getline(cin, s))
  22. {
  23. if(s.size()==0)break;
  24. n++;
  25. a[s]++;
  26. }
  27.  
  28. double ans;
  29.  
  30. for(it=a.begin(); it!=a.end(); it++)
  31. {
  32. s=it->first;
  33. int x=it->second;
  34. ans=x*100.0/(double) n;
  35. cout<<s<<" ";
  36. cout<<fixed<<setprecision(4)<<ans<<endl;
  37. }
  38.  
  39. if(i!=t) cout<<endl;
  40.  
  41. }
  42. return 0;
  43. }
  44. /*
  45. 1
  46.  
  47. Red Alder
  48. Ash
  49. Aspen
  50. Basswood
  51. Ash
  52. Beech
  53. Yellow Birch
  54. Ash
  55. Cherry
  56. Cottonwood
  57. Ash
  58. Cypress
  59. Red Elm
  60. Gum
  61. Hackberry
  62. White Oak
  63. Hickory
  64. Pecan
  65. Hard Maple
  66. White Oak
  67. Soft Maple
  68. Red Oak
  69. Red Oak
  70. White Oak
  71. Poplan
  72. Sassafras
  73. Sycamore
  74. Black Walnut
  75. Willow
  76.  
  77. */
  78.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement