## 10101 - Bangla Numbers

Moderator: Board moderators

algoJo
New poster
Posts: 37
Joined: Sun Dec 17, 2006 9:02 am
Try these:
INPUT

Code: Select all

``````000001
00000101
0101
001000
001001
001011
1000
1001
1011
0
1
12
``````
OUTPUT

Code: Select all

``````   1. 1
2. 1 shata 1
3. 1 shata 1
4. 1 hajar
5. 1 hajar 1
6. 1 hajar 11
7. 1 hajar
8. 1 hajar 1
9. 1 hajar 11
10. 0
11. 1
12. 12

``````
check your output format and be sure that there is no extra space at the end of output.

andysoft
Experienced poster
Posts: 109
Joined: Sat Jun 23, 2007 9:53 pm
Location: Brest, BELARUS
Contact:
Hi everyone.
I am always getting WA in this problem. Every time.
I have implemented all hints posted there (like removing space in the end of output) and so on, but WA continues.
Please, can someone share with me some test cases, probably specific and unusual - I cannot find any mistake in my code...

Btw,

Code: Select all

``````program Project1;

{\$APPTYPE CONSOLE}

var
s,t: string;
i,j,k,ci: integer;
soc: set of char;

procedure doyourtime;
var
fl: boolean;
begin
fl := false;
if length(s) >= 8 then
begin
for i:=1 to length(s) - 8 + 1 do
begin
if fl then
write (s[i])
else
if s[i]<>'0' then
begin
fl := true;
write (s[i])
end;
end;
if fl then write (' ');
write ('kuti ');
delete (s,1,length(s)-8+1);
while s[1] = '0' do
begin
delete (s,1,1);
if length(s)=0 then break
end;
end;
fl := false;
if length(s) >= 6 then
begin
for i:=1 to length(s) - 6 + 1 do
begin
if fl then
write (s[i])
else
if s[i]<>'0' then
begin
fl := true;
write (s[i])
end;
end;
if fl then write (' ');
write ('lakh ');
delete (s,1,length(s)-6+1);
while s[1] = '0' do
begin
delete (s,1,1);
if length(s)=0 then break
end;
end;
fl := false;
if length(s) >= 4 then
begin
for i:=1 to length(s) - 4 + 1 do
begin
if fl then
write (s[i])
else
if s[i]<>'0' then
begin
fl := true;
write (s[i])
end;
end;
if fl then write (' ');
write ('hajar ');
delete (s,1,length(s)-4+1);
while s[1] = '0' do
begin
delete (s,1,1);
if length(s)=0 then break
end;
end;
fl := false;
if length(s) >= 3 then
begin
for i:=1 to length(s) - 3 + 1 do
begin
if fl then
write (s[i])
else
if s[i]<>'0' then
begin
fl := true;
write (s[i])
end;
end;
if fl then write (' ');
write ('shata ');
delete (s,1,length(s)-3+1);
while s[1] = '0' do
begin
delete (s,1,1);
if length(s)>0 then break
end;
end;
end;

begin
soc := ['0'..'9'];
ci := 0;
while not eof do
begin
ci := ci + 1;
while not (s[length(s)] in soc) do
delete (s,length(s),1);
write (ci:4,'. ');
while s[1] = '0' do
begin
delete (s,1,1);
if length(s)=0 then break
end;
if length(s)=0 then
begin
writeln (0);
continue
end;
t := s;
if length(s)>=10 then
begin
t := s;
delete (t,1,length(t)-9);
delete (s,length(s)-8,9);
s := s + '00';
doyourtime;
end;
s := t;

doyourtime;

if length(s) > 0 then
write (s);

writeln
end;
end.
``````
Now I lay me down to sleep...
my profile

mohsincsedu
Learning poster
Posts: 63
Joined: Tue Sep 20, 2005 12:31 am
Location: Dhaka
Contact:

### WA

I got PE some month ago..

But i lost my code...

try to solve by recursion but WA.
plz help..

here is my code:

Code: Select all

``````Remove after AC :)
I have a silly mistake....:(
``````

Amra korbo joy akhdin............................

Tushee
New poster
Posts: 1
Joined: Mon Aug 27, 2007 11:45 am
Please someone help me, its make me crazy :S
my code gives PE, but WHY?!O.o

[code}
Accepted
[/code]

hahahaken
New poster
Posts: 26
Joined: Tue May 27, 2008 10:42 am

### Re: 10101 - Bangla Numbers

Here's how I solve the problem not using hard code
1. Use "/" and "%" to extract one or two integer(s) from the input and use an integer array of size 9 to store them
As the max number is 999999999999999, which is 15 digits, the max size the input number can be divided is 9, according to the sample output
Try to refer to the second output and you will know when to extract one integer and when to extract two
2. When the stored number is not zero, print the number together with the words "kuti", "lakh"...
As an integer array is used to store the numbers, there is not neccessary to worry about the problem of "01 hajar", "1 shata 00" ...
3. Think of when to output one more "kuti"
4. Try to handle the spaces between the numbers and words
5. Rememeber to add a number before each output, otherwise you will get a wrong answer even you manage to control the output properly
6. Set the width of each output number to four, otherwise you will get a presentation error

DJWS
Learning poster
Posts: 100
Joined: Sat Oct 11, 2003 3:30 pm
Location: Taiwan
Contact:

### Re: 10101 - Bangla Numbers

You can solve this problem with the Divide and Conquer approach.

hahahaken
New poster
Posts: 26
Joined: Tue May 27, 2008 10:42 am

### Re: 10101 - Bangla Numbers

DJWS wrote:You can solve this problem with the Divide and Conquer approach.
How? Can you explain a little bit?

DJWS
Learning poster
Posts: 100
Joined: Sat Oct 11, 2003 3:30 pm
Location: Taiwan
Contact:

### Re: 10101 - Bangla Numbers

Okay. Think about the expression of a Bangla number. See what is before 'kuti' and what is after 'kuti.'
Try to keep your code clean and short, with a simple recursion.

BTW, 999999999999999 can be stored in a 'long long int'-type variable.
Last edited by DJWS on Fri Aug 22, 2008 6:45 am, edited 1 time in total.

Obaida
A great helper
Posts: 380
Joined: Wed Jan 16, 2008 6:51 am

### Re: 10101 - Bangla Numbers

I lost hope.

Code: Select all

``removed``
Last edited by Obaida on Sat Nov 15, 2008 6:59 am, edited 1 time in total.
try_try_try_try_&&&_try@try.com
This may be the address of success.

Obaida
A great helper
Posts: 380
Joined: Wed Jan 16, 2008 6:51 am

### Re: 10101 - Bangla Numbers

Please any one post any critical input for which my code is not working.
The main thing is that in my compiler i can't work with the long long variables so using long i can check till 1 shata kuti
So i need test case to get accepted.
try_try_try_try_&&&_try@try.com
This may be the address of success.

Mohiuddin
New poster
Posts: 6
Joined: Fri Apr 25, 2008 12:09 pm

### Re: 10101 - Bangla Numbers

here is the code - #include <stdio.h>
#include <string.h>

int index;

void recur(char *str,int j,int k)
{
int temp;

if(j<index)
{
return;
}
if(k==0)
{
k=k+2;
recur(str,j-2,k);
if(j-1<index)
temp=(str[j]-'0');
else
temp=(str[j-1]-'0')*10+(str[j]-'0');
if(temp!=0)
printf("%d",temp);
return;
}

if(k==2)
{
k=k+1;
recur(str,j-1,k);
if(str[j]!='0')
printf("%c shata ",str[j]);
return;

}
if(k==3)
{
k=(k+2)%9;
recur(str,j-2,k);
if(j-1<index)
temp=(str[j]-'0');
else
temp=(str[j-1]-'0')*10+(str[j]-'0');
if(temp!=0)
printf("%d hajar ",temp);
return;
}
if(k==5)
{
k=(k+2);
recur(str,j-2,k);
if(j-1<index)
temp=(str[j]-'0');
else
temp=(str[j-1]-'0')*10+(str[j]-'0');
if(temp!=0)
printf("%d lakh ",temp);
return;
}
if(k==7)
{
k=2;
recur(str,j-2,k);
if(j-1<index)
temp=(str[j]-'0');
else
temp=(str[j-1]-'0')*10+(str[j]-'0');

if(temp!=0)
printf("%d ",temp);
printf("kuti ");
return;
}

}

int main ()
{
char str[100];
int i,j,k=1,t;
while(gets(str))
{
i=0;
index=0;
printf("%4d. ",k);
j=strlen(str);
for(t=0;t<j;t++)
{

if(str[t]!='0')
break;
index++;
}
if(t>=j)
{
printf("0\n");
continue;
}
recur(str,j-1,i);
k++;
printf("\n");
}
return 0;
}

Obaida
A great helper
Posts: 380
Joined: Wed Jan 16, 2008 6:51 am

### Re: 10101 - Bangla Numbers

I can't get is accepted yet. I hope some one 2 help me. This is crazy.

Code: Select all

``removed``
Last edited by Obaida on Tue Feb 10, 2009 9:29 am, edited 1 time in total.
try_try_try_try_&&&_try@try.com
This may be the address of success.

Obaida
A great helper
Posts: 380
Joined: Wed Jan 16, 2008 6:51 am

### Re: 10101 - Bangla Numbers

Some 1 plz plz help my new code why got CE????
I don't know how much wa i got from it..... only thing it's too much!

And what will be the output for 0.

Code: Select all

``removed``
Last edited by Obaida on Sun Jul 05, 2009 8:38 pm, edited 1 time in total.
try_try_try_try_&&&_try@try.com
This may be the address of success.

vahid sanei
Learning poster
Posts: 84
Joined: Fri Jan 09, 2009 4:37 pm
Location: IRAN

### Re: 10101 - Bangla Numbers

Obaida
What is "sata" ?
Impossible says I`m possible

Obaida
A great helper
Posts: 380
Joined: Wed Jan 16, 2008 6:51 am