## 344 - Roman Digititis

Moderator: Board moderators

FlyDeath
Learning poster
Posts: 73
Joined: Wed Jan 02, 2002 2:00 am
Location: Taiwan
I count and count again, and I always get that for input "99" output for "x" is 146(I count it by hand!).
I think there must be something I dont know.
is lxxxix for 89?Or there is something I special?
Thanks

..
A great helper
Posts: 454
Joined: Thu Oct 18, 2001 2:00 am
Location: Hong Kong
yes, 89 is LXXXIX
Let me guess, do you think that
49 = IL and 99 = IC ?

<font size=-1>[ This Message was edited by: .. on 2002-02-05 18:20 ]</font>

FlyDeath
Learning poster
Posts: 73
Joined: Wed Jan 02, 2002 2:00 am
Location: Taiwan
I fixed it like you told me:49 is xlix,and 99 is xcix,but i still get WA.Here is my code:

Code: Select all

``````#include <stdio.h>
#include <math.h>

void main()
{
int num[101][5];
int i,j;
int sum[101][5];
int in;
for(i=0;i<101;i++)
{
for(j=0;j<5;j++)
{
num[i][j]=0;
sum[i][j]=0;
}
}
for(i=1;i<101;i++)
{
for(j=0;j<5;j++)
num[i][j]=num[i-1][j];
num[i][0]++;
if(num[i][0]==4)
{
num[i][0]=-1;
num[i][1]++;
}
if(num[i][1]==2)
{
num[i][1]=0;
num[i][2]++;
}
if(num[i][2]==4&&num[i][0]!=-1)
{
num[i][2]=-1;
num[i][3]++;
}
if(num[i][3]==2)
{
num[i][3]=0;
num[i][4]++;
}
}
num[49][2]=2;
num[99][2]=2;
for(i=1;i<101;i++)
for(j=0;j<5;j++)
sum[i][j]=sum[i-1][j]+fabs(num[i][j]);
while(scanf("%d",&in)!=EOF)
{
if(in==0)
break;
printf("%d: %d i, %d v, %d x, %d l, %d cn",in,sum[in][0],sum[in][1],sum[in][2],sum[in][3],sum[in][4]);
}
}
``````

Caesum
Experienced poster
Posts: 225
Joined: Fri May 03, 2002 12:14 am
Location: UK
Contact:
that should work fine, make sure your line is not too long in the email, or split it

New poster
Posts: 4
Joined: Fri Aug 02, 2002 5:06 pm

### WA for this code

hello,
i don't know why i get WA for this code.

[c]
#include<stdio.h>
#define MAX 100

void main()
{
int i,n[MAX],no,ni,nv,nx,nl,nc,one,ten,j;
char temp[120];
int s[100][5];
i=0;
while(1)
{
scanf("%d",&n);
if(n == 0)
break;
i++;
}
no = i;
s[0][0] = 1;
s[0][1] = s[0][2] = s[0][3] = s[0][4] = 0;
for(i=1;i<100;i++)
{
ni = nv = nx = nl = nc = 0;
one = (i+1) % 10;
ten = (i+1) / 10;
if(one == 9)
{
nx = nx + 1;
ni = ni+1;
}
else if( one >= 5)
{
nv = nv + 1;
ni = ni + one - 5;
}
else if(one == 4)
{
nv = nv + 1;
ni = ni +1;
}
else if(one > 0)
ni = ni + one;
if(ten == 10)
{
nc = nc +1;
}
else if(ten == 9)
{
nc = nc + 1;
nx = nx +1;
}
else if(ten >= 5)
{
nl = nl + 1;
nx = nx +ten - 5;
}
else if(ten == 4)
{
nx = nx + 1;
nl = nl + 1;
}
else if(ten > 0)
nx = nx + ten;

s[0] = s[i-1][0]+ni;
s[1] = s[i-1][1]+nv;
s[2] = s[i-1][2]+nx;
s[3] = s[i-1][3]+nl;
s[4] = s[i-1][4]+nc;
}
for(i=0;i<no;i++)
{
j = n -1;
if(j<0 || j > 99)
continue;
printf("%d: %d i, %d v, %d x, %d l, %d c\n",n,s[j][0],s[j][1],s[j][2],s[j][3],s[j][4]);
}
}

[/c]

ayaw
New poster
Posts: 18
Joined: Fri May 23, 2003 3:52 pm
Contact:
i get WA too...

this is mine...
pliz help me...

Code: Select all

``````#include <stdio.h>
#include <stdlib.h>

int I,V,X,L,C;

void proccess(int n) {
int i,x;
for(i=1;i<=n;i++) {
x = i/10;
if(x>=9) { C++; x-=10; }
if(x>=4) { L++; x-=5; }
x = abs(x);
X+=x;
x = i%10;
if(x>=9)  { X++; x-=10; }
if(x>=4)  { V++; x-=5; }
x = abs(x);
I+=x;
}
}

main () {
int n;
while(1) {
scanf("%d",&n);
if(n==0) return 0;
I=V=X=L=X=0;
proccess(n);
printf("%d: %d i, %d v, %d x, %d l, %d c\n",n,I,V,X,L,C);
}
}
``````
peace...

wamorimjr
New poster
Posts: 4
Joined: Wed Oct 08, 2003 4:50 am

### 344 - Roman Digititis

People,
I have a problem with the 344. I submited it but I received a wrong answer mail. I tried a input file with all numbers between 1 an 100 and it seems to be right.
Could someone help me. The code is above:

Code: Select all

``````[c]
/*@BEGIN_OF_SOURCE_CODE
/*   @JUDGE_ID:   32478CA   344   C   */

#include <stdio.h>
#include <fcntl.h>
#include <sys/stat.h>
#include <sys/types.h>

/*---------------------------------------------------*/
/* seguintes posi``````

UFP2161
A great helper
Posts: 277
Joined: Mon Jul 21, 2003 7:49 pm
Contact:
The only thing different from your output and my AC ouput is that I have an extra newline at the end of the file. Should be PE, but hey, who knows?

HerrAachen
New poster
Posts: 12
Joined: Sat Apr 03, 2004 11:01 pm
You forgot to reset your C-value. It is being added up without ever being set back.

Herr Aachen

nayyer kazmi
New poster
Posts: 3
Joined: Thu Sep 23, 2004 9:59 am

### Roman digits

#include<iostream.h>
void main(void)
{

int i=0,v=0,x=0,l=0,c=0,num,temp;

cout<<"Enter any decimal number";
cin>>num;
for(int n=1;n<=num;n++)
{
temp=n;

c+=temp/100;
temp=temp%100;
c+=temp/90;
x+=temp/90;
temp=temp%90;
l+=temp/50;
temp=temp%50;
l+=temp/40;
x+=temp/40;
temp=temp%40;
x+=temp/10;
temp=temp%10;
x+=temp/9;
i+=temp/9;
temp=temp%9;
v+=temp/5;
temp=temp%5;
v+=temp/4;
i+=temp/4;
temp=temp%4;
i+=temp/1;
temp=temp%1;

}

cout<<num<<": "<<i <<" i, "<<v<<" v, "<<x<<" x, "<<l<<" l, "<<c<<" c";

}

nayyer kazmi
New poster
Posts: 3
Joined: Thu Sep 23, 2004 9:59 am

### Nayyer

#include<iostream.h>
void main(void)
{

int i=0,v=0,x=0,l=0,c=0,num,temp;

cout<<"Enter any decimal number";
cin>>num;
for(int n=1;n<=num;n++)
{
temp=n;

c+=temp/100;
temp=temp%100;
c+=temp/90;
x+=temp/90;
temp=temp%90;
l+=temp/50;
temp=temp%50;
l+=temp/40;
x+=temp/40;
temp=temp%40;
x+=temp/10;
temp=temp%10;
x+=temp/9;
i+=temp/9;
temp=temp%9;
v+=temp/5;
temp=temp%5;
v+=temp/4;
i+=temp/4;
temp=temp%4;
i+=temp/1;
temp=temp%1;

}

cout<<num<<": "<<i <<" i, "<<v<<" v, "<<x<<" x, "<<l<<" l, "<<c<<" c";

}

nayyer kazmi
New poster
Posts: 3
Joined: Thu Sep 23, 2004 9:59 am

### Re: Roman digits

nayyer kazmi wrote:#include<iostream.h>
void main(void)
{

int i=0,v=0,x=0,l=0,c=0,num,temp;

cout<<"Enter any decimal number";
cin>>num;
for(int n=1;n<=num;n++)
{
temp=n;

c+=temp/100;
temp=temp%100;
c+=temp/90;
x+=temp/90;
temp=temp%90;
l+=temp/50;
temp=temp%50;
l+=temp/40;
x+=temp/40;
temp=temp%40;
x+=temp/10;
temp=temp%10;
x+=temp/9;
i+=temp/9;
temp=temp%9;
v+=temp/5;
temp=temp%5;
v+=temp/4;
i+=temp/4;
temp=temp%4;
i+=temp/1;
temp=temp%1;

}

cout<<num<<": "<<i <<" i, "<<v<<" v, "<<x<<" x, "<<l<<" l, "<<c<<" c";

}

FearNLoath
New poster
Posts: 1
Joined: Mon Jan 14, 2008 8:38 pm

### 344 - Roman Digitus?

I've gone through and manually checked all the numbers 1-99, and my program gets them all right... I keep getting WA though...anyone know why?

Code: Select all

``````/* Response to PROBLEM 344 - Roman Digitus */

#include <iostream>
using namespace std;
int main()
{

int count[101];
int i[101];
int v[101];
int x[101];
int l[101];
int c[101];
int var = -1;

while(count[var] != 0)
{
var++;
cin >> count[var];
}

var = 0;
while(count[var] != 0)
{
cout << "\n" << count[var];
i[var] = 0;
v[var] = 0;
x[var] = 0;
l[var] = 0;
c[var] = 0;

while( 0 < count[var])
{
if((count[var] % 5) == 4 || (count[var] % 5) == 1){i[var]++;}
else if((count[var] % 5) == 3){i[var]+=3;}
else if((count[var] % 5) == 2){i[var]+=2;}
if((count[var] % 10) < 9 && (count[var] % 10) > 3){v[var]++;}
if((count[var] < 90) && (count[var] > 39)){l[var]++;}
if((count[var] - 90) >= 0){c[var]++;}

if((count[var] % 50) > 8){x[var]++;}
if((count[var] % 50) > 18 && (count[var] % 50) < 40){x[var]++;}
if((count[var] % 50) > 28 && (count[var] % 50) < 40){x[var]++;}
if((count[var] % 50) == 39 || (count[var] % 50) == 49){x[var]++;}

count[var]--;
}
cout << ": " << i[var] << " i, ";
cout << v[var] << " v, ";
cout << x[var] << " x, ";
cout << l[var] << " l, ";
cout << c[var] << " c";
var++;
}
return 0;
}``````
[/code]

sohel
Guru
Posts: 856
Joined: Thu Jan 30, 2003 5:50 am
Location: New York
http://online-judge.uva.es/board/viewto ... hlight=344

Search the board first. If you finding an existing thread for your problem then make your post there.
Don't create a new one.

WAandAC
New poster
Posts: 4
Joined: Sat Nov 03, 2007 4:32 am

### Re: 344 Problem

Why WA? I have already checked several outputs.

Code: Select all

``````#include <iostream>
using namespace std;
int main ()
{
int s1[101];
int s5 [101];
int s10[101];
int s50 [101];
int s100 [101];

s1 [1] = 1;
s5 [1] = 0;
s10 [1] = 0;
s50 [1] = 0;
s100 [1] = 0;

for (int i = 2; i <= 100; i++)
{
if (i%10 == 1 || i%10 == 2|| i %10 == 3||
i%10 == 6 || i%10 ==7
|| i%10 ==8)
{
s1 [i] = s1[i-1] + 1;
s5 [i] = s5 [i-1];
s10 [i] = s10 [i-1];
s50 [i] = s50 [i-1];
s100 [i] = s100 [i-1];

}else if (i%10 == 4)
{
s1 [i] = s1[i-1] - 2;
s5 [i] = s5 [i-1] + 1;
s10 [i] = s10 [i-1];
s50 [i] = s50 [i-1];
s100 [i] = s100 [i-1];
}else if (i%10 == 5)
{
s1 [i] = s1[i-1] - 1;
s5 [i] = s5 [i-1];
s10 [i] = s10 [i-1];
s50 [i] = s50 [i-1];
s100 [i] = s100 [i-1];
}else if (i%10 == 9)
{	s1 [i] = s1[i-1] - 2;
s5 [i] = s5 [i-1] - 1;
s10 [i] = s10 [i-1] + 1;
s50 [i] = s50 [i-1];
s100 [i] = s100 [i-1];
}else if (i%10 == 0)
{
if (i<=30 || (i >= 60 && i <= 80) )
{
s1 [i] = s1[i-1] - 1;
s5 [i] = s5 [i-1] ;
s10 [i] = s10 [i-1];
s50 [i] = s50 [i-1];
s100 [i] = s100 [i-1];
}else if  (i == 40)
{
s1 [i] = s1[i-1] - 1;
s5 [i] = s5 [i-1] ;
s10 [i] = s10 [i-1] - 3;
s50 [i] = s50 [i-1] + 1;
s100 [i] = s100 [i-1];
}else if  (i == 50)
{
s1 [i] = s1[i-1] - 1;
s5 [i] = s5 [i-1] ;
s10 [i] = s10 [i-1] - 2;
s50 [i] = s50 [i-1] ;
s100 [i] = s100 [i-1];

}else if  (i == 90)
{
s1 [i] = s1[i-1] - 1;
s5 [i] = s5 [i-1] ;
s10 [i] = s10 [i-1] - 3;
s50 [i] = s50 [i-1] - 1;
s100 [i] = s100 [i-1] + 1;
}else if  ( i = 100)
{
s1 [i] = 0;
s5 [i] = 0;
s10 [i] = 0;
s50 [i] = 0;
s100 [i] = 1;
}

}
}

int t1[101];
int t5 [101];
int t10[101];
int t50 [101];
int t100 [101];

t1 [1] = 0;
t5 [1] = 0;
t10 [1] = 0;
t50 [1] = 0;
t100 [1] = 0;

for ( int  i = 1; i <= 100;i++)
{
t1 [i] = t1[i-1] + s1[i];
t5 [i] = t5[i-1] + s5[i];
t10 [i] = t10[i-1] + s10[i];
t50 [i] = t50[i-1] + s50[i];
t100 [i] = t100[i-1] + s100[i];
}
int val = -1;
while (scanf("%d", &val) == 1)
{
if (val == 0)break;
printf ("%d: %d i, %d v, %d x, %d l, %d c\n", val, t1[val], t5[val], t10[val], t50[val], t100[val]);
}
return 0;
}

``````