Advertisement
Imran2544

Roman Digititis

Jan 31st, 2019
149
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.13 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. int i[110],v[110],x[110],l[110],c[110];
  4. string Ar_to_Ro(int q)
  5. {
  6.     string ans="";
  7.     map<int,string>wq;
  8.     map<int,string>::reverse_iterator g;
  9.     wq[1000]="m";
  10.     wq[900]="cm";
  11.     wq[500]="d";
  12.     wq[400]="cd";
  13.     wq[100]="c";
  14.     wq[90]="xc";
  15.     wq[50]="l";
  16.     wq[40]="xl";
  17.     wq[10]="x";
  18.     wq[9]="ix";
  19.     wq[5]="v";
  20.     wq[4]="iv";
  21.     wq[1]="i";
  22.     for(g=wq.rbegin(); g!=wq.rend(); g++)
  23.     {
  24.         while(q>=g->first)
  25.         {
  26.             ans+=(g->second);
  27.             q-=g->first;
  28.         }
  29.     }
  30.     return ans;
  31. }
  32. void cnt()
  33. {
  34.     string s;
  35.     for(int j=1; j<=100; j++)
  36.     {
  37.         s=Ar_to_Ro(j);
  38.         //cout<<s<<endl;
  39.         for(int k=0; s[k]; k++)
  40.         {
  41.             if(s[k]=='i')i[j]++;
  42.             else if(s[k]=='v')v[j]++;
  43.             else if(s[k]=='x')x[j]++;
  44.             else if(s[k]=='l')l[j]++;
  45.             else if(s[k]=='c')c[j]++;
  46.         }
  47.     }
  48. }
  49. int main()
  50. {
  51.     cnt();
  52.     int n;
  53.     while(cin>>n && n)
  54.     {
  55.         printf("%d: %d i,%d v, %d x, %d l, %d c\n",n,i[n],v[n],x[n],l[n],c[n]);
  56.     }
  57.     return 0;
  58. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement