## 10101 - Bangla Numbers

Moderator: Board moderators

You're printing out some unnecissary "null" charactors.
For my test data, Your program output:
Code: Select all
`   1. 1   2. 10   3. 1 hajar^@   4. 10 hajar^@   5. 1 lakh^@   6. 10 lakh kuti^@   7. 9 kuti 99 lakh 99 hajar 9 shata 99 kuti 99 lakh 99 hajar 9 shata 99   8. 45 lakh 89 hajar 7 shata 45 kuti 89 lakh 73 hajar 9 shata 58`

where ^@ represents charactor 0.
dpitts
New poster

Posts: 31
Joined: Tue Jun 17, 2003 10:10 pm

### ^.^

Thanks Dreamer's kindly help~
kenneth_cwc
New poster

Posts: 9
Joined: Sat Oct 18, 2003 2:08 pm

I'm getting WA as well, and I really don't see why I should be. My program handles the number 0 (just prints 0), a leading 0 in an interior term (e.g. "09 lakh" becomes "9 lakh"), and an interior term which is completely 0 (the term is not printed). Is this another correct-but-not-accepted solution?

[cpp]
#include <iostream>
#include <stdio.h>
#include <string>

using namespace std;

/* The current word-term */
string ident;

/* returns the min of two ints */
int min(int a, int b)
{
if (a > b)
return b;
return a;
}

/* Goes to the next word-term */
{
if (ident == "" || ident == " kuti ")
ident = " shata ";
else if (ident == " shata ")
ident = " hajar ";
else if(ident == " hajar ")
ident = " lakh ";
else
ident = " kuti ";
}

/* Takes care of leading zeroes */
bool checkit(string & s)
{
while (s.length())
{
if (s.at(0) != '0')
break;
s = s.substr(1);
}
return s.length();
}

/* Takes the end off the string and returns the
* text version of that portion which was removed */
string chop_and_print(string &in)
{
string result;
int length = 2;
if (ident == " shata ")
length = 1;
length = min(length, in.length());
result = in.substr(in.length() - length);
in = in.substr(0, in.length() - length);
if (!checkit(result))
return "";
result.append(ident);
return result;
}

int main()
{
string line, output = "";
int solutioncount = 0;
while (cin >> line)
{
printf("%4d. ", ++solutioncount);
ident = output = "";
if (line == "0")
output = "0";
else
{
while (line.length())
{
output = chop_and_print(line) + output;
}
}
cout << output << endl;
}
return 0;
}

[/cpp]
_-(GPI)-_

"Finally I have freed myself from the clutches of the garbage fairy!"

GreenPenInc
Learning poster

Posts: 53
Joined: Sat May 01, 2004 9:31 pm

for whom who also suffered W.A.

one of the trap is that maybe there are trailing spaces after the last case! I encountered it and A.C. now
coconut
New poster

Posts: 7
Joined: Thu May 27, 2004 7:23 pm
Location: Honolulu

GreenPenInc wrote:My program handles the number 0 (just prints 0), a leading 0 in an interior term (e.g. "09 lakh" becomes "9 lakh"), and an interior term which is completely 0 (the term is not printed). Is this another correct-but-not-accepted solution?

I got AC with C today.
Following is input I used for local test.
Please try to check, ... I can't read program well except for C.
Code: Select all
`11212310002376445897458973958999999999999999909090090909009100000010000000100000000000000400000000400000[EOF]`

And, next is right output.
Code: Select all
`   1. 1   2. 12   3. 1 shata 23   4. 1 hajar   5. 23 hajar 7 shata 64   6. 45 lakh 89 hajar 7 shata 45 kuti 89 lakh 73 hajar 9 shata 58   7. 9 kuti 99 lakh 99 hajar 9 shata 99 kuti 99 lakh 99 hajar 9 shata 99   8. 9 kuti 9 lakh 9 hajar 9 kuti 9 lakh 9 hajar 9   9. 1 kuti 1 kuti  10. 1 kuti kuti  11. 40 lakh kuti 40 hajar  12. 0[EOF]`

In this problem, we have no need to do a fear of the following type of input being prepared.
Code: Select all
`01001234000000000000000[EOF]`

This type of number is the mistaken numerical value.
My program don't treat this input, but could get AC.

Best regards.
tan_Yui
Experienced poster

Posts: 155
Joined: Sat Jul 10, 2004 12:41 am

Thank you very much, tan_Yui.
Things are simple, but we make them complex.
matrix2
New poster

Posts: 19
Joined: Wed Jul 21, 2004 11:14 am
Location: Suceava, Romania

### 10101 why gives P.E

here is my code.

#include<stdio.h>
#include<math.h>
double n;
double a[18];int i=1,j,k;

void f(double t)
{
double m;

while(t!=0)
{
m=fmod(t,10);
t=floor(t/10);
a[i]=m;
i++;
}

}

void main()
{
while(1==scanf("%lf",&n))
{
if(n<=999999999999999.00&&n>=0)
{
if(n!=0)
f(n);
i--;
j++;
printf("%d. ",j);
if(n==0)
printf("0");
while(i!=0)
{
switch(i)
{
case 1:{
if(a[i]!=0||k==1)
{
printf("%.0lf",a[i]);
k=0;
}
i--;
break;
}
case 2:{
if(a[i]!=0)
{
printf("%.0lf",a[i]);
k=1;
}
i--;
break;
}
case 3:
{
if(a[i]!=0)
printf("%.0lf shata ",a[i]);
i--;
break;
}
case 4:
{
if(a[i]!=0||k==1)
{
printf("%.0lf hajar ",a[i]);
k=0;
}
i--;
break;
}
case 5:
{
if(a[i]!=0)
{
printf("%.0lf",a[i]);
k=1;
}
i--;

break;
}
case 6:
{
if(a[i]!=0||k==1)
{ printf("%.0lf lakh ",a[i]);
k=0;}
i--;

break;
}
case 7:
{
if(a[i]!=0)
{printf("%.0lf",a[i]);
k=1;}
i--;

break;
}
case 8:
{
if(a[i]!=0||k==1)
{
printf("%.0lf kuti ",a[i]);
k=0;
}
else
printf(" kuti ");
i--;
break;
}
case 9:
{
if(a[i]!=0)
{printf("%.0lf",a[i]);
k=1;}
i--;
break;
}
case 10:
{
if(a[i]!=0)
printf("%.0lf shata ",a[i]);
i--;
break;
}
case 11:
{
if(a[i]!=0||k==1)
{printf("%.0lf hajar ",a[i]);
k=0;}
i--;

break;
}
case 12:
{
if(a[i]!=0)
{printf("%.0lf",a[i]);
k=1;}
i--;

break;
}
case 13:
{
if(a[i]!=0||k==1)
{ printf("%.0lf lakh ",a[i]);
k=0;}
i--;

break;
}
case 14:
{
if(a[i]!=0)
{printf("%.0lf",a[i]);
k=1;}
i--;

break;
}
case 15:
{
if(a[i]!=0)
printf("%.0lf kuti ",a[i]);
i--;
break;
}
}
}
printf("\n");
}
else break;
i=1;
}
}
efr_shovo
New poster

Posts: 38
Joined: Wed Sep 22, 2004 9:09 am

For each case of input, you have to output a line starting with the case number with four digits adjustment followed by the converted text.

You should output according to the upper cautions.

This is input.
Code: Select all
`11212310002376445897458973958999999999999999909090090909009100000010000000100000000000000400000000400000[EOF]`

And, this is output.
Code: Select all
`   1. 1   2. 12   3. 1 shata 23   4. 1 hajar   5. 23 hajar 7 shata 64   6. 45 lakh 89 hajar 7 shata 45 kuti 89 lakh 73 hajar 9 shata 58   7. 9 kuti 99 lakh 99 hajar 9 shata 99 kuti 99 lakh 99 hajar 9 shata 99   8. 9 kuti 9 lakh 9 hajar 9 kuti 9 lakh 9 hajar 9   9. 1 kuti 1 kuti  10. 1 kuti kuti  11. 40 lakh kuti 40 hajar  12. 0[EOF]`

Your output for above input is the following.
Code: Select all
`1. 12. 123. 1 shata 234. 1 hajar 5. 23 hajar 7 shata 646. 45 lakh 89 hajar 7 shata 45 kuti 89 lakh 73 hajar 9 shata 587. 9 kuti 99 lakh 99 hajar 9 shata 99 kuti 99 lakh 99 hajar 9 shata 998. 9 kuti 9 lakh 9 hajar 9 kuti 9 lakh 9 hajar 99. 1 kuti 1 kuti 10. 1 kuti  kuti 11. 40 lakh  kuti 40 hajar 12. 0[EOF]`

And, it seems that your program outputs the blanks beyond necessity.
Improve your code as compared with the right output.

Best regards.
tan_Yui
Experienced poster

Posts: 155
Joined: Sat Jul 10, 2004 12:41 am

tan_Yui:
In this problem, we have no need to do a fear of the following type of input being prepared.

Code: Select all
`01 001234 000000000000000 [EOF] `

This type of number is the mistaken numerical value.
My program don't treat this input, but could get AC.

Hello! tan_Yui
There could be input like this:
Code: Select all
`000001000000etc.`

So we need to think about them when we take input as srting.
you may use double for taking input thats why they could create any problem for you.

A1
Experienced poster

Posts: 173
Joined: Wed Jan 28, 2004 3:34 pm

I faced lots of troubles with this problem and finally identified few points and got accepted.

1. There is a cycle. Check it properly.
2. Fix your code for this type of input : 10 kuti kuti 1 shata 1
3. There is an input, it is 0 (zero). What is your output for this input ?
4. I am not sure but I have handled Blank Line also.

I hope now you will get it accepted.
[/quote]
Please join The ACM Solver Group at Yahoo
http://groups.yahoo.com/group/acm_solver/
Niaz
Learning poster

Posts: 77
Joined: Fri Dec 17, 2004 11:06 am
Location: East West University, Dhaka, Bangladesh

### 10101-WA=> help me please :)

Heyah :]
I am a quite fresh and unexperienced computer scientist and I ask for help.
As I've noticed the vast majority uses c/c++ etc. However, I've written my program in PASCAL and I hope that won't be any obstalce.

var
l,wp,spr:string;
i,j,n,le:longint;

procedure wypisz;
Begin
if n>999 then write(n,'.') else
if n>99 then write(' ',n,'.') else
if n>9 then write(' ',n,'.') else
write(' ',n,'.')
End;

procedure zero(p:longint);
Begin
if (l[p]='0')then begin
if l[p+1]='0' then begin
wp:='' ;
spr:='';
end else wp:=l[p+1] end else
wp:=l[p]+l[p+1];
End;

BEGIN
while not(eof) do Begin
inc(n);
le:=length(l);
spr:='0';
for i:=le downto 1 do if l[i]<>'0' then spr:=l[i];
if spr='0' then begin
wypisz;
writeln(' 0');
end else begin

spr:='a';
if le<8 then
if le<6 then
if le<4 then
if le<3 then begin
wypisz;
if(l[1]='')or(l[1]='0') then begin
if(le=2)then writeln(' ',l[2])
else writeln(' 0');end
else writeln(' ',l)
end else
begin {3}
wypisz;
if l[1]<>'0'then write(' ',l[1],' shata');
zero(2);
if wp<>'' then writeln(' ',wp) else writeln
end else
begin {4,5}
wypisz;
if le=4 then begin if l[1]<>'0'then write (' ',l[1],' hajar')end else
begin zero(1); if wp<>'' then write(' ',wp,' hajar'); end;
if l[le-2]<>'0'then write(' ',l[le-2],' shata');
zero(le-1);
if wp<>'' then writeln(' ',wp) else writeln;
end else
begin {6,7}
wypisz;
if le=6 then begin if l[1]<>'0'then write (' ',l[1],' lakh')end else
begin zero(1); if wp<>'' then write(' ',wp,' lakh'); end;
zero(le-4); if wp<>'' then write(' ',wp,' hajar');
if l[le-2]<>'0'then write(' ',l[le-2],' shata');
zero(le-1);
if wp<>'' then writeln(' ',wp) else writeln;
end

else
if le<15 then
if le<13 then
if le<11 then
if le<10 then begin {8,9}
wypisz;
if le=8 then begin if l[1]<>'0'then write (' ',l[1],' kuti')end else
begin zero(1); write(' ',wp,' kuti'); end;
zero(le-6); if wp<>'' then write(' ',wp,' lakh');
zero(le-4); if wp<>'' then write(' ',wp,' hajar');
if l[le-2]<>'0'then write(' ',l[le-2],' shata');
zero(le-1);
if wp<>'' then writeln(' ',wp) else writeln;
end
else begin
wypisz; {10}
if l[1]<>'0'then write(' ',l[1],' shata');
zero(2); if wp<>'' then write(' ',wp,' kuti');
if (wp='')and(l[1]<>'0') then write(' kuti');
zero(4); if wp<>'' then write(' ',wp,' lakh');
zero(le-4);if wp<>'' then write(' ',wp,' hajar');
if l[le-2]<>'0'then write(' ',l[le-2],' shata');
zero(le-1);
if wp<>'' then writeln(' ',wp) else writeln;
end
else begin {11,12}
wypisz;
if le=11 then begin if l[1]<>'0'then write (' ',l[1],' hajar')end else
begin zero(1); if wp<>'' then write(' ',wp,' hajar'); end;
if l[le-9]<>'0'then write(' ',l[le-9],' shata');
zero(le-8); if (wp<>'') then write(' ',wp,' kuti');
if (wp='')and((l[le-9]<>'0')or(wp<>'')) then write(' kuti');
zero(le-6); if wp<>'' then write(' ',wp,' lakh');
zero(le-4);if wp<>'' then write(' ',wp,' hajar');
if l[le-2]<>'0'then write(' ',l[le-2],' shata');
zero(le-1);
if wp<>'' then writeln(' ',wp) else writeln;
end
else begin {13,14}
wypisz;
if le=13 then begin if l[1]<>'0'then write (' ',l[1],' lakh')end else
begin zero(1); if wp<>'' then write(' ',wp,' lakh'); end;
zero(le-11);if wp<>'' then write(' ',wp,' hajar');
if l[le-9]<>'0'then write(' ',l[le-9],' shata');
zero(le-8); if wp<>'' then write(' ',wp,' kuti');
if (wp='')and((l[le-9]<>'0')or(wp<>'')) then write(' kuti');
zero(le-6); if wp<>'' then write(' ',wp,' lakh');
zero(le-4);if wp<>'' then write(' ',wp,' hajar');
if l[le-2]<>'0'then write(' ',l[le-2],' shata');
zero(le-1);
if wp<>'' then writeln(' ',wp) else writeln;
end
else begin {15}
wypisz;
if l[1]<>'0' then write(' ',l[1],' kuti');
zero(le-13);if wp<>'' then write(' ',wp,' lakh');
zero(le-11);if wp<>'' then write(' ',wp,' hajar');
if l[le-9]<>'0'then write(' ',l[le-9],' shata');
zero(le-8); if wp<>''
then write(' ',wp,' kuti');
if (wp='')and((l[le-9]<>'0')or(wp<>'')) then write(' kuti');
zero(le-6); if wp<>'' then write(' ',wp,' lakh');
zero(le-4);if wp<>'' then write(' ',wp,' hajar');
if l[le-2]<>'0'then write(' ',l[le-2],' shata');
zero(le-1);
if wp<>'' then writeln(' ',wp) else writeln;
end;

end;

End;
END.
ANNA
New poster

Posts: 1
Joined: Mon Jan 24, 2005 4:12 am

input
Code: Select all
`23764458974589739581010100100010000100000100000010000000100000000100000000010000000000100000000000100000000000010000000000000100000000000000999999999999999`

and my(ACed) output
Code: Select all
`   1. 23 hajar 7 shata 64   2. 45 lakh 89 hajar 7 shata 45 kuti 89 lakh 73 hajar 9 shata 58   3. 1   4. 0   5. 10   6. 1 shata   7. 1 hajar   8. 10 hajar   9. 1 lakh  10. 10 lakh  11. 1 kuti  12. 10 kuti  13. 1 shata kuti  14. 1 hajar kuti  15. 10 hajar kuti  16. 1 lakh kuti  17. 10 lakh kuti  18. 1 kuti kuti  19. 9 kuti 99 lakh 99 hajar 9 shata 99 kuti 99 lakh 99 hajar 9 shata 99`

Hope it helps!
keep it real!

jaracz
Learning poster

Posts: 79
Joined: Sun Sep 05, 2004 3:54 pm
Location: Poland

### 10101 WA Help!

I m getting WA for my submission
I have test it for all cases on given on the forum

Here is my code::

ACC

Last edited by vinay on Sun Jun 25, 2006 1:53 pm, edited 1 time in total.
If I will myself do hashing, then who will do coding !!!

vinay
Experienced poster

Posts: 104
Joined: Thu Apr 13, 2006 2:26 pm
Location: India

Input:
Code: Select all
`100000010000000 100000000000000`

Check this,
Your code gives Wrong output for these.

Code: Select all
`if(kase<10){ cout<<" "; } else if(kase<100){ cout<<" "; } else if(kase<1000){ cout<<" "; } `

change it to:
Code: Select all
`if(kase<10){ cout<<"   "; } else if(kase<100){ cout<<"  "; } else if(kase<1000){ cout<<" "; } `

emotional blind
A great helper

Posts: 383
Joined: Mon Oct 18, 2004 8:25 am

emotional blind wrote:Input:
Code: Select all
`100000010000000 100000000000000`

Check this,
Your code gives Wrong output for these.

My code gives these output:

1. 1 kuti 1 kuti
2. 1 kuti kuti

What is th correct output?
If I will myself do hashing, then who will do coding !!!

vinay
Experienced poster

Posts: 104
Joined: Thu Apr 13, 2006 2:26 pm
Location: India

PreviousNext