10101 - Bangla Numbers

All about problems in Volume 101. If there is a thread about your problem, please use it. If not, create one with its number in the subject.

Moderator: Board moderators

dpitts
New poster
Posts: 31
Joined: Tue Jun 17, 2003 10:10 pm

Post by dpitts »

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.

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

^.^

Post by kenneth_cwc »

Thanks Dreamer's kindly help~
:D :lol:

GreenPenInc
Learning poster
Posts: 53
Joined: Sat May 01, 2004 9:31 pm
Contact:

Post by GreenPenInc »

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 */
void advance()
{
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;
advance();
}
}
cout << output << endl;
}
return 0;
}


[/cpp]
_-(GPI)-_

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

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

Post by coconut »

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

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

Post by tan_Yui »

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

1
12
123
1000
23764
45897458973958
999999999999999
909090090909009
100000010000000
100000000000000
40000000040000
0
[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

01
001234
000000000000000
[EOF]
This type of number is the mistaken numerical value.
My program don't treat this input, but could get AC.

Best regards.

matrix2
New poster
Posts: 19
Joined: Wed Jul 21, 2004 11:14 am
Location: Suceava, Romania
Contact:

Post by matrix2 »

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

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

10101 why gives P.E

Post by efr_shovo »

why 10101gives P.E. Please Help me.

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=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!=0||k==1)
{
printf("%.0lf",a);
k=0;
}
i--;
break;
}
case 2:{
if(a!=0)
{
printf("%.0lf",a);
k=1;
}
i--;
break;
}
case 3:
{
if(a!=0)
printf("%.0lf shata ",a);
i--;
break;
}
case 4:
{
if(a!=0||k==1)
{
printf("%.0lf hajar ",a);
k=0;
}
i--;
break;
}
case 5:
{
if(a!=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;
}
}

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

Post by tan_Yui »

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

1
12
123
1000
23764
45897458973958
999999999999999
909090090909009
100000010000000
100000000000000
40000000040000
0
[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. 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]
And, it seems that your program outputs the blanks beyond necessity.
Improve your code as compared with the right output.

Best regards.

A1
Experienced poster
Posts: 173
Joined: Wed Jan 28, 2004 3:34 pm
Location: Bangladesh

Post by A1 »

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

000001
000000
etc.
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.

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

Post by Niaz »

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/

J&Jewel
New poster
Posts: 50
Joined: Thu Jul 31, 2003 10:43 am
Location: Daffodil University,Dhaka,Bangladesh
Contact:

10101(Bangla number) W/A

Post by J&Jewel »

#include<stdio.h>
#include<string.h>
char input[16];
void rev(int len)
{
char temp;
int len1=len;
for(int i=0;i<len/2;i++)
{
temp=input[len1-1];
input[len1-1]=input;
input=temp;
len1--;
}
}
int main()
{
int i,len,l1,cas=0;
//freopen("F:\\10101.txt","r",stdin);
while(gets(input)!=NULL)
{
printf("%4d.",++cas);
l1=0;
len = strlen(input);
rev(len);
if(len>7)
{
l1=len-7;
len=len-l1;
}
int loop=1;
for(i=l1;i>=1;i--)
{

if(i==1 && loop ==1) if(input[i+7-1]!='0') printf(" %c",input[i+7-1]);
if(i==8)
{
if(input[i+7-1]!='0')
{
printf(" %c kuti",input[i+7-1]);
}
i--;
}
if(i>=6)
{
if(i>6)
{
if(input[i+7-1]!='0')
{
printf(" %c%c lukh",input[i+7-1],input[i+7-2]);
i=i-2;
}
else
{
printf(" %c lukh",input[i+7-2]);
i=i-2;
}
}
else
{
if(input[i+7-1]!='0')
{
printf(" %c lukh",input[i+7-1]);
i--;
}
}
}
loop=5;
if(i>=4)
{
if(i>4)
{
if(input[i+7-1]!='0') printf(" %c%c hajar",input[i+7-1],input[i+7-2]);
else if(input[i+7-2]!='0') printf(" %c hajar",input[i+7-2]);
}
else if(input[i+7-1]!='0') printf(" %c hajar",input[i+7-1]);
i--;
}
if(i==3)
{
if(input[i+7-1]!='0') printf(" %c shata",input[i+7-1]);
}
if(i==2)
{
if(input[i+7-1]!='0') printf(" %c%c",input[i+7-1],input[i+7-2]);
else if(input[i+7-2]!='0') printf(" %c",input[i+7-2]);
}
}
if(l1!=0) printf(" kuti");
for(i=len;i>=1;i--)
{
if(i>=6)
{
if(i>6)
{
if(input[i-1]!='0')
{
printf(" %c%c lukh",input[i-1],input[i-2]);
i=i-2;
}
else
{
if (input[i-2]!='0') printf(" %c lukh",input[i-2]);
i=i-2;
}

}
else
{
if(input[i-1]!='0')
{
printf(" %c lukh",input[i-1]);
i--;
}
}
}
if(i>=4)
{
if(i>4)
{
if(input[i-1]!='0') printf(" %c%c hajar",input[i-1],input[i-2]);
else if(input[i-2]!='0') printf(" %c hajar",input[i-2]);
}
else if(input[i-1]!='0') printf(" %c hajar",input[i-1]);
i--;

}
if(i==3)
{
if(input[i-1]!='0') printf(" %c shata",input[i-1]);
}
if(i==2)
{
if(input[i-1]!='0') printf(" %c%c",input[i-1],input[i-2]);
else if(input[i-2]!='0') printf(" %c",input[i-2]);
i=i-2;
}
if(i==1) {
printf(" %c",input[i-1]);
}
}
printf("\n");
}
return 0;
}
I hate Wrong Answer!

CodeMaker
Experienced poster
Posts: 183
Joined: Thu Nov 11, 2004 12:35 pm
Location: AIUB, Bangladesh

Post by CodeMaker »

Hi, check this test case:

Input:

100000000000000

your output:

1. 1 kuti 0 lukh kuti

my output:

1. 1 kuti kuti

there will be nothing like 0 lakh or 0 hajar.......there could be many other problems too, but I could not check because of time....if you don't get Acc after fixing this mistake then post again... :wink:
Jalal : AIUB SPARKS

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

10101-WA=> help me please :)

Post by ANNA »

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);
readln(l);
le:=length(l);
spr:='0';
for i:=le downto 1 do if l<>'0' then spr:=l;
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.

J&Jewel
New poster
Posts: 50
Joined: Thu Jul 31, 2003 10:43 am
Location: Daffodil University,Dhaka,Bangladesh
Contact:

Post by J&Jewel »

Yes thanks I get accepted...... :lol: Only i have problem in 0 lakh.
I hate Wrong Answer!

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

Post by jaracz »

I didn't read your code, here's input which may help you

input

Code: Select all

23764
45897458973958
1
0
10
100
1000
10000
100000
1000000
10000000
100000000
1000000000
10000000000
100000000000
1000000000000
10000000000000
100000000000000
999999999999999
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!

Post Reply

Return to “Volume 101 (10100-10199)”