3963 - CIVIC DILL MIX (Runtime Error)

Do you want to discuss about these problems? Go now!
Users are shared (no need to re-register).

Moderator: Board moderators

Post Reply
User avatar
RoMeLuKo
New poster
Posts: 7
Joined: Mon Jan 02, 2006 1:44 am
Location: Puno - Peru
Contact:

3963 - CIVIC DILL MIX (Runtime Error)

Post by RoMeLuKo » Mon Dec 07, 2009 11:47 am

Why RE?
Code works fine with "official" testcases.
http://acm.ashland.edu/2007/Problem-Set/Data/A.in
http://acm.ashland.edu/2007/Problem-Set/Data/A.out
Thanks in advance.

Code: Select all

/*Rommel Anatoli Quintanilla Cruz*/
/*06 de Diciembre del 2009*/
/*RE*/

#include <iostream>
#include <string>

using namespace std;

char s[7]={'I','V','X','L','C','D','M'};
int v[7]={1,5,10,50,100,500,1000};

string us[10]={"","I","II","III","IV","V","VI","VII","VIII","IX"};
string ds[10]={"","X","XX","XXX","XL","L","LX","LXX","LXXX","XC"};
string cs[10]={"","C","CC","CCC","CD","D","DC","DCC","DCCC","CM"};
string ums[5]={"","M","MM","MMM","MMMM"};

int aValor(char c)
{
for(int I=0;I<7;I++)
  if(s[I]==c)
   return v[I];
return 0;
}

int aEntero(string romano)
{
int tmp=0;
for(unsigned int I=0;I<romano.length();I++)
{
  if(aValor(romano[I])<aValor(romano[I+1]))
  {
   tmp+=aValor(romano[I+1])-aValor(romano[I]);
   I++;
  }
  else
   tmp+=aValor(romano[I]);
}
return tmp;
}

string aRomano(int entero)
{
string u="";
string d="";
string c="";
string m="";

int unidades=entero%10;
u=us[unidades];
entero/=10;
if(entero>0)
{
  int decenas=entero%10;
  d=ds[decenas];
  entero/=10;
  if(entero>0)
  {
   int centenas=entero%10;
   c=cs[centenas];
   entero/=10;
   if(entero>0)
   {
    int umillar=entero%10;
    m=ums[umillar];
   }
  }
}
return m+c+d+u;
}


int main()
{
int k=1;
int n;
while(true)
{
  cin>>n;
  if(n==0)
   return 0;

  int tmp=0;
  for(int I=0;I<n;I++)
  {
   string palabra;
   cin>>palabra;
   tmp+=aEntero(palabra);
  }
  cout<<"Case "<<aRomano(k++)<<": "<<aRomano(tmp)<<endl;
}
return 0;
}
Luck!

User avatar
RoMeLuKo
New poster
Posts: 7
Joined: Mon Jan 02, 2006 1:44 am
Location: Puno - Peru
Contact:

Re: 3963 - CIVIC DILL MIX (Runtime Error)

Post by RoMeLuKo » Wed Mar 10, 2010 1:28 am

I got AC, RE was converted in AC.
:P
Luck!

Post Reply

Return to “ACM ICPC Archive Board”