Saleh127

UVA 344

Jul 27th, 2020
174
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.99 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. #define test int t; cin>>t; while (t--)
  4. #define ll long long int
  5. #define fellow_junior ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
  6. int main()
  7. {
  8. fellow_junior
  9. int a,d,e,j,k;
  10. while(cin>>a &&a)
  11. {
  12. string x="";
  13. for(j=1; j<=a; j++)
  14. {
  15. d=j;
  16. while(d>0)
  17. {
  18. if(d>=100)
  19. {
  20. x+='C';
  21. d-=100;
  22. }
  23. else if(d>=90)
  24. {
  25. x+='X';
  26. x+='C';
  27. d-=90;
  28. }
  29. else if(d>=50)
  30. {
  31. x+='L';
  32. d-=50;
  33. }
  34. else if(d>=40)
  35. {
  36. x+='X';
  37. x+='L';
  38. d-=40;
  39. }
  40. else if(d>=10)
  41. {
  42. x+='X';
  43. d-=10;
  44. }
  45. else if(d>=9)
  46. {
  47. x+='I';
  48. x+='X';
  49. d-=9;
  50. }
  51. else if(d>=5)
  52. {
  53. x+='V';
  54. d-=5;
  55. }
  56. else if(d>=4)
  57. {
  58. x+='I';
  59. x+='V';
  60. d-=4;
  61. }
  62. else if(d>=1)
  63. {
  64. x+='I';
  65. d-=1;
  66. }
  67. }
  68. }
  69. int i=0,v=0,xx=0,l=0,c=0;
  70. for(k=0;k<x.size();k++)
  71. {
  72. if(x[k]=='I') i++;
  73. else if(x[k]=='V') v++;
  74. else if(x[k]=='X') xx++;
  75. else if(x[k]=='L') l++;
  76. else if(x[k]=='C') c++;
  77. }
  78. printf("%d: %d i, %d v, %d x, %d l, %d c\n",a,i,v,xx,l,c);
  79. }
  80. return 0;
  81. }
  82.  
Advertisement
Add Comment
Please, Sign In to add comment