Page **6** of **9**

Posted: **Tue Mar 27, 2007 3:03 am**

by **algoJo**

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.

Posted: **Fri Jul 13, 2007 1:10 pm**

by **andysoft**

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;
readln (s);
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.
```

### WA

Posted: **Sun Aug 19, 2007 1:55 pm**

by **mohsincsedu**

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....:(
```

Thanks in Adv..

Posted: **Mon Aug 27, 2007 11:48 am**

by **Tushee**

Please someone help me, its make me crazy :S

my code gives PE, but WHY?!O.o

[code}

Accepted

[/code]

### Re: 10101 - Bangla Numbers

Posted: **Sun Jun 08, 2008 2:17 pm**

by **hahahaken**

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

### Re: 10101 - Bangla Numbers

Posted: **Mon Jun 09, 2008 8:49 am**

by **DJWS**

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

### Re: 10101 - Bangla Numbers

Posted: **Mon Jun 09, 2008 1:53 pm**

by **hahahaken**

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

How? Can you explain a little bit?

### Re: 10101 - Bangla Numbers

Posted: **Mon Jun 09, 2008 3:18 pm**

by **DJWS**

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.

### Re: 10101 - Bangla Numbers

Posted: **Thu Jul 31, 2008 11:55 am**

by **Obaida**

Some one please please please ...... please check my code. (which got more then 20 WA!!!)

I lost hope.

### Re: 10101 - Bangla Numbers

Posted: **Tue Aug 05, 2008 8:13 am**

by **Obaida**

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.

### Re: 10101 - Bangla Numbers

Posted: **Mon Aug 11, 2008 8:32 pm**

by **Mohiuddin**

Please help me..why i m getting wrong answer? i have checked all possible inputs..but...please pzzzzz help..

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;

}

### Re: 10101 - Bangla Numbers

Posted: **Sat Nov 15, 2008 7:01 am**

by **Obaida**

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

### Re: 10101 - Bangla Numbers

Posted: **Tue Feb 10, 2009 6:14 am**

by **Obaida**

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.

### Re: 10101 - Bangla Numbers

Posted: **Tue Feb 10, 2009 10:46 am**

by **vahid sanei**

Obaida

What is "sata" ?

### Re: 10101 - Bangla Numbers

Posted: **Mon Mar 16, 2009 8:31 am**

by **Obaida**

Some one please help me i am getting CE constantly...

I spent so many time on it... But got CE again and again.