Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- using namespace std;
- int i[110],v[110],x[110],l[110],c[110];
- string Ar_to_Ro(int q)
- {
- string ans="";
- map<int,string>wq;
- map<int,string>::reverse_iterator g;
- wq[1000]="m";
- wq[900]="cm";
- wq[500]="d";
- wq[400]="cd";
- wq[100]="c";
- wq[90]="xc";
- wq[50]="l";
- wq[40]="xl";
- wq[10]="x";
- wq[9]="ix";
- wq[5]="v";
- wq[4]="iv";
- wq[1]="i";
- for(g=wq.rbegin(); g!=wq.rend(); g++)
- {
- while(q>=g->first)
- {
- ans+=(g->second);
- q-=g->first;
- }
- }
- return ans;
- }
- void cnt()
- {
- string s;
- for(int j=1; j<=100; j++)
- {
- s=Ar_to_Ro(j);
- //cout<<s<<endl;
- for(int k=0; s[k]; k++)
- {
- if(s[k]=='i')i[j]++;
- else if(s[k]=='v')v[j]++;
- else if(s[k]=='x')x[j]++;
- else if(s[k]=='l')l[j]++;
- else if(s[k]=='c')c[j]++;
- }
- }
- }
- int main()
- {
- cnt();
- int n;
- while(cin>>n && n)
- {
- printf("%d: %d i,%d v, %d x, %d l, %d c\n",n,i[n],v[n],x[n],l[n],c[n]);
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement