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

Re: 10101 - Bangla Numbers

Postby hahahaken » Mon Jun 09, 2008 1:53 pm

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

Postby DJWS » Mon Jun 09, 2008 3:18 pm

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. :wink:

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

Postby Obaida » Thu Jul 31, 2008 11:55 am

Some one please please please ...... please check my code. (which got more then 20 WA!!!)
I lost hope. :cry: :cry: :cry:
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
Location: (BUBT) Dhaka,Bagladesh.

Re: 10101 - Bangla Numbers

Postby Obaida » Tue Aug 05, 2008 8:13 am

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
Location: (BUBT) Dhaka,Bagladesh.

Re: 10101 - Bangla Numbers

Postby Mohiuddin » Mon Aug 11, 2008 8:32 pm

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

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

Postby Obaida » Sat Nov 15, 2008 7:01 am

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
Location: (BUBT) Dhaka,Bagladesh.

Re: 10101 - Bangla Numbers

Postby Obaida » Tue Feb 10, 2009 6:14 am

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
Location: (BUBT) Dhaka,Bagladesh.

Re: 10101 - Bangla Numbers

Postby vahid sanei » Tue Feb 10, 2009 10:46 am

Obaida
What is "sata" ? :D
Impossible says I`m possible
User avatar
vahid sanei
Learning poster
 
Posts: 84
Joined: Fri Jan 09, 2009 4:37 pm
Location: IRAN

Re: 10101 - Bangla Numbers

Postby Obaida » Mon Mar 16, 2009 8:31 am

Some one please help me i am getting CE constantly...
I spent so many time on it... But got CE again and again. :oops: :oops: :oops:
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
Location: (BUBT) Dhaka,Bagladesh.

Re: 10101 - Bangla Numbers

Postby mf » Mon Mar 16, 2009 8:57 am

Obaida wrote:Some one please help me i am getting CE constantly...


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. :oops: :oops: :oops:

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

Postby Obaida » Mon Mar 16, 2009 9:19 am

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
Location: (BUBT) Dhaka,Bagladesh.

Re: 10101 - Bangla Numbers

Postby f(_irt » Sat Mar 28, 2009 4:13 am

i don't know why i am getting WA......
Is thr any problem with a null after each input.....
plzz reply...
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 :oops:
satisfaction is end of life..............
f(_irt
New poster
 
Posts: 1
Joined: Sat Mar 28, 2009 4:09 am

Re: 10101 - Bangla Numbers

Postby lnr » Thu Jun 25, 2009 8:29 am

Can anyone give some special input output?

I tested these.
Are they correct?
input:
Code: Select all
999999999999999
101010101010101
010101010101010
100000000000001
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++);
User avatar
lnr
Experienced poster
 
Posts: 134
Joined: Sat Jun 30, 2007 2:52 pm
Location: (DU,CSE)Dhaka,Bangladesh

Re: 10101 - Bangla Numbers

Postby lnr » Thu Jun 25, 2009 9:23 am

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?
User avatar
lnr
Experienced poster
 
Posts: 134
Joined: Sat Jun 30, 2007 2:52 pm
Location: (DU,CSE)Dhaka,Bangladesh

Re: 10101 - Bangla Numbers

Postby Obaida » Thu Jul 02, 2009 8:36 am

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
Location: (BUBT) Dhaka,Bagladesh.

PreviousNext

Return to Volume CI

Who is online

Users browsing this forum: No registered users and 1 guest