10101 - Bangla Numbers

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

Moderator: Board moderators

Postby dpitts » Fri Mar 26, 2004 12:20 pm

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

^.^

Postby kenneth_cwc » Wed Apr 07, 2004 9:56 pm

Thanks Dreamer's kindly help~
:D :lol:
kenneth_cwc
New poster
 
Posts: 9
Joined: Sat Oct 18, 2003 2:08 pm

Postby GreenPenInc » Wed May 12, 2004 11:32 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 */
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!"
User avatar
GreenPenInc
Learning poster
 
Posts: 53
Joined: Sat May 01, 2004 9:31 pm

Postby coconut » Thu Jul 15, 2004 8:52 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

Postby tan_Yui » Sun Sep 26, 2004 1:52 pm

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.
tan_Yui
Experienced poster
 
Posts: 155
Joined: Sat Jul 10, 2004 12:41 am

Postby matrix2 » Mon Sep 27, 2004 12:48 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

Postby efr_shovo » Wed Sep 29, 2004 9:01 am

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[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

Postby tan_Yui » Wed Sep 29, 2004 6:06 pm

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.
tan_Yui
Experienced poster
 
Posts: 155
Joined: Sat Jul 10, 2004 12:41 am

Postby A1 » Tue Nov 09, 2004 2:46 pm

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.
User avatar
A1
Experienced poster
 
Posts: 173
Joined: Wed Jan 28, 2004 3:34 pm
Location: Bangladesh

Postby Niaz » Sat Dec 18, 2004 8:05 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 :)

Postby ANNA » Mon Jan 24, 2005 4:30 am

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[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

Postby jaracz » Tue Jul 05, 2005 12:45 am

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!
User avatar
jaracz
Learning poster
 
Posts: 79
Joined: Sun Sep 05, 2004 3:54 pm
Location: Poland

10101 WA Help!

Postby vinay » Thu Jun 22, 2006 7:18 am

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

Here is my code::

ACC



Please help :cry:

thanks in advance
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 !!!
User avatar
vinay
Experienced poster
 
Posts: 104
Joined: Thu Apr 13, 2006 2:26 pm
Location: India

Postby emotional blind » Thu Jun 22, 2006 7:26 pm

Input:
Code: Select all
100000010000000
100000000000000


Check this,
Your code gives Wrong output for these.

another additionnal thing

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<<" ";
}
User avatar
emotional blind
A great helper
 
Posts: 383
Joined: Mon Oct 18, 2004 8:25 am
Location: Bangladesh

Postby vinay » Fri Jun 23, 2006 8:18 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 !!!
User avatar
vinay
Experienced poster
 
Posts: 104
Joined: Thu Apr 13, 2006 2:26 pm
Location: India

PreviousNext

Return to Volume CI

Who is online

Users browsing this forum: Bing [Bot] and 1 guest