#include<iostream> #include<map> #define db(a) cout << #a << " = " << a << endl; using namespace std; int main() { int n; string romanos[] = {"c", "xc", "l", "xl", "x", "ix", "v", "iv", "i"}; char rom[] = {'c', 'l', 'x', 'v', 'i'}; int val[] = {100, 90, 50, 40, 10, 9, 5, 4, 1}; while(cin >> n) { if(n == 0) break; mapmapa; for (int k = 1; k <= n; k++) { int m = k; string cad = ""; for (int i = 0; i < 9; i++) { int div = m / val[i]; m = m % val[i]; for (int u = 0; u < div; u++) { cad += romanos[i]; } } //db(cad); for (int i = 0; i < cad.size(); i++) mapa[cad[i]]++; } cout << n << ": "; for (int i = 4; i >= 0; i--) { if(i != 0) cout << mapa[rom[i]] << " " << rom[i] << ", "; else cout << mapa[rom[i]] << " " << rom[i]; } cout << endl; } return 0; }
miércoles, 19 de octubre de 2011
344 - Roman Digititis - UVA
Suscribirse a:
Enviar comentarios (Atom)
No hay comentarios:
Publicar un comentario