## 10101 - Bangla Numbers

Moderator: Board moderators

### Re: 10101 - Bangla Numbers

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

How? Can you explain a little bit?
hahahaken
New poster

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

### 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.
DJWS
Learning poster

Posts: 100
Joined: Sat Oct 11, 2003 3:30 pm
Location: Taiwan

### 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.
Obaida
A great helper

Posts: 380
Joined: Wed Jan 16, 2008 6:51 am

### Re: 10101 - Bangla Numbers

here is the code - [code][/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;
}
Mohiuddin
New poster

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

### 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.
Obaida
A great helper

Posts: 380
Joined: Wed Jan 16, 2008 6:51 am

### Re: 10101 - Bangla Numbers

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

vahid sanei
Learning poster

Posts: 84
Joined: Fri Jan 09, 2009 4:37 pm
Location: IRAN

### Re: 10101 - Bangla Numbers

I spent so many time on it... But got CE again and again.
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

My compiler prints "error: integer constant is too large for ‘long’ type", for every large integer in your code.
Consider appending LL suffix to each of them, so that the compiler will treat them as 64-bit integers.
E.g. write 100000000000000LL instead of 100000000000000.

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

There's a very easy way for you to avoid CEs - install and use gcc compiler to compile your program, like the judge does.
Most Linux distributions include gcc by default, so you may also want to install one of them, too.
If you need to use Windows, try Cygwin, or Mingw (ports of gcc to windows)
mf
Guru

Posts: 1244
Joined: Mon Feb 28, 2005 4:51 am
Location: Zürich, Switzerland

### Re: 10101 - Bangla Numbers

Thank you mf. You taught me a good lesson. I really need such Suggestions.
Now i need some test case to avoid WA.
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

i don't know why i am getting WA......
Is thr any problem with a null after each input.....
this is my code---
Code: Select all
`//10101 bangla numbers#include<iostream>#include<cstring>#include<vector>using namespace std;static long long int kuti = 10000000;static long long int lakh = 100000;static long long int hazar = 1000;static long long int shata = 100;string s;//vector<string>vs;string give_no(long long int m){      string sm;            if(m/10==1)sm="1";       else if(m/10==2)sm="2";       else if(m/10==3)sm="3";       else if(m/10==4)sm="4";       else if(m/10==5)sm="5";       else if(m/10==6)sm="6";       else if(m/10==7)sm="7";       else if(m/10==8)sm="8";       else if(m/10==9)sm="9";                   if(m%10==0)sm+="0 ";       else if(m%10==1)sm+="1 ";       else if(m%10==2)sm+="2 ";              else if(m%10==3)sm+="3 ";       else if(m%10==4)sm+="4 ";       else if(m%10==5)sm+="5 ";       else if(m%10==6)sm+="6 ";       else if(m%10==7)sm+="7 ";       else if(m%10==8)sm+="8 ";       else if(m%10==9)sm+="9 ";              return sm;       }string give_result(string s,long long int n){            long long int loc=n/kuti;               if(loc==0);//return 0 and break        else{             s+=give_result(s,loc);             s+="kuti ";                             }         n=n%kuti;            long long int k,l,h,sh;         l = n/lakh;         if(l!=0){         s+=give_no(l);                        s+="lakh ";}                  h = (n%lakh)/hazar;         if(h!=0){         s+=give_no(h);         s+="hazar ";         }         sh = (n%hazar)/shata;         if(sh!=0)         {s+=give_no(sh);          s+="shata ";                  }         k=n%shata;          if(k!=0)          s+=give_no(k);                         return s;       }       int main(){    long long int n;    int count=0;    while(cin>>n){ count++;                   s="";                   if(n!=0)                   s = give_result(s,n);                   else                   s = "0";                    cout.width(4);                   cout<<count<<". "<<s<<endl;                                                                        }                system("pause");    return 0;    }`

plz help
satisfaction is end of life..............
f(_irt
New poster

Posts: 1
Joined: Sat Mar 28, 2009 4:09 am

### Re: 10101 - Bangla Numbers

Can anyone give some special input output?

I tested these.
Are they correct?
input:
Code: Select all
`999999999999999101010101010101010101010101010100000000000001 100000000000`

output:
Code: Select all
`   1. 9 kuti 99 lakh 99 hajar 9 shata 99 kuti 99 lakh 99 hajar 9 shata 99     2. 1 kuti 1 lakh 1 hajar 10 kuti 10 lakh 10 hajar 1 shata 1     3. 10 lakh 10 hajar 1 shata 1 kuti 1 lakh 1 hajar 10     4. 1 kuti kuti 1     5. 10 hajar kuti `

Is it correct?
Code: Select all
` printf("%4d. ", cs++);`

lnr
Experienced poster

Posts: 134
Joined: Sat Jun 30, 2007 2:52 pm

### Re: 10101 - Bangla Numbers

Now getting presentation error.
Is there any newline after the last line of output?
And at the end of a line can a space character cause presentation error?

lnr
Experienced poster

Posts: 134
Joined: Sat Jun 30, 2007 2:52 pm

### Re: 10101 - Bangla Numbers

I think new line causes wrong answer..
mistake in printing space cause pe..
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