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

Post Reply
johnplayers
New poster
Posts: 5
Joined: Mon Apr 03, 2006 12:52 pm

10101 - Bangla numbers (WA)

Post by johnplayers »

Hi,
Sorry for starting another thread but I cannot get AC for Bangla numbers - 10101.

Code: Select all

Removed after getting accepted.
That is the code and it passed all the test cases previously posted on this forum. I would be glad, if someone could point out the mistake.

Thanx.
Last edited by johnplayers on Thu Jun 22, 2006 7:14 am, edited 1 time in total.
emotional blind
A great helper
Posts: 383
Joined: Mon Oct 18, 2004 8:25 am
Location: Bangladesh
Contact:

Post by emotional blind »

your algorithm is very much right.
But you got CE for this line:

Code: Select all

cout<<unit<<;
change it to

Code: Select all

cout<<unit;

Dont forget to remove your code after getting ACCEPTED
johnplayers
New poster
Posts: 5
Joined: Mon Apr 03, 2006 12:52 pm

Post by johnplayers »

Thank you for your reply.
I finally got accepted!!

Thank you.
vinay
Experienced poster
Posts: 104
Joined: Thu Apr 13, 2006 2:26 pm
Location: India
Contact:

10101 WA Help!

Post by vinay »

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 !!!
emotional blind
A great helper
Posts: 383
Joined: Mon Oct 18, 2004 8:25 am
Location: Bangladesh
Contact:

Post by emotional blind »

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<<" "; 
} 
vinay
Experienced poster
Posts: 104
Joined: Thu Apr 13, 2006 2:26 pm
Location: India
Contact:

Post by vinay »

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 !!!
emotional blind
A great helper
Posts: 383
Joined: Mon Oct 18, 2004 8:25 am
Location: Bangladesh
Contact:

Post by emotional blind »

vinay wrote: My code gives these output:

1. 1 kuti 1 kuti
2. 1 kuti kuti

What is th correct output?
your code gives

Code: Select all

 1. 1 kuti 1 kuti
 2. 1 kuti kuti kuti
another input

Code: Select all

1000000100000000
10000001000000000
your output

Code: Select all

 1. kuti 10 kuti kuti
 2. kuti 1 shata kuti kuti
vinay
Experienced poster
Posts: 104
Joined: Thu Apr 13, 2006 2:26 pm
Location: India
Contact:

Post by vinay »

emotional blind wrote:
your code gives

Code: Select all

 1. 1 kuti 1 kuti
 2. 1 kuti kuti kuti
Not at all its giving correct answer :-?
1. 1 kuti 1 kuti
2. 1 kuti kuti

And the second set inputs that u gave were
greater than 999999999999999, the limit given in the input..

Still can't find the error

:(
If I will myself do hashing, then who will do coding !!!
emotional blind
A great helper
Posts: 383
Joined: Mon Oct 18, 2004 8:25 am
Location: Bangladesh
Contact:

Post by emotional blind »

I executed your prgram on several occation in my PC.

and

INPUT

Code: Select all

100000010000000 
100000000000000
your program gives

OUTPUT

Code: Select all

 1. 1 kuti 1 kuti
 2. 1 kuti kuti kuti
I was very careful this time.


I think you have sent an older version of your code,
and now you are checking the input with the newer version of your code,
that you have made after you have posted older one.
vinay
Experienced poster
Posts: 104
Joined: Thu Apr 13, 2006 2:26 pm
Location: India
Contact:

Post by vinay »

Thanks I got ACC :lol:
I don't know why the same code differntly on my compiler.
I checked on my friend's compiler and fixed the problem.
But I don't why this problem arose :wink:

Thanks emotional blind :lol:
If I will myself do hashing, then who will do coding !!!
razor_blue
New poster
Posts: 27
Joined: Mon Nov 27, 2006 4:44 am
Location: Indonesia

Post by razor_blue »

I still have WA for this problem. Anyone can help me?
Give me critical input & output, plz....

Code: Select all

#include<stdio.h>
#include<stdlib.h>
#include<string.h>
typedef struct data node;
struct data
{
	char kuti,lakh,hajar,shata;
	node *next;
} *head,*curr;
void push(char a,char b,char c,char d)
{
	curr=(node*)malloc(sizeof(node));
	curr->kuti=a; curr->lakh=b; curr->hajar=c; curr->shata=d;	
	curr->next=NULL;
	if(!head)
	{
		head=curr;	
	}
	else
	{
		curr->next=head;
		head=curr;	
	}
}
void popall(void)
{
	while(head)
	{
		curr=head;
		head=head->next;
		free(curr);	
	}	
}
int main()
{
	int i,j,kas=1,len;
	char bil[50],a,b,c,d,e,flag;
	while(gets(bil))
	{
		if(strlen(bil)<3) 
		{ 
			printf("%4d. %s\n",kas,bil);
			kas++; continue; 
		}
		if(atoi(bil)==0) 
		{ 
			printf("%4d. 0\n",kas);
			kas++; continue; 
		}
		len=strlen(bil);
		for(flag=i=0;i<len;i++)
		{
			if(bil[i]=='0'&&flag==0)
			{
				for(j=1;j<len;j++) bil[j-1]=bil[j];
				bil[len-1]='\0'; len--;
			}
			else if(bil[i]!='0') flag=1;
		}
		a=b=c=d=flag=0; 
		e=(bil[len-2]-'0')*10+(bil[len-1]-'0');
		for(i=len-3;i>=0;i--)
		{
			if(flag==0)	
			{
				d=bil[i]-'0'; flag++;				
			}
			else if(flag==1)
			{
				c=bil[i]-'0'; flag++;
			}
			else if(flag==2)
			{
				c+=10*(bil[i]-'0'); flag++;				
			}
			else if(flag==3)
			{
				b=bil[i]-'0'; flag++;
			}
			else if(flag==4)
			{
				b+=10*(bil[i]-'0'); flag++;	
			}
			else if(flag==5)
			{
				a=bil[i]-'0'; flag++;
			}
			else if(flag==6)
			{
				a+=10*(bil[i]-'0'); 
				push(a,b,c,d); flag=0;	
			}
		}	
		if(flag==1) push(0,0,0,d);
		else if(flag==2) push(0,0,c,d);
		else if(flag==3) push(0,0,c,d);
		else if(flag==4) push(0,b,c,d);		
		else if(flag==5) push(0,b,c,d);
		else if(flag==6) push(a,b,c,d);
		printf("%4d. ",kas);
		for(curr=head;curr;curr=curr->next)
		{
			if(curr->kuti)	printf("%d kuti ",curr->kuti);	
			if(curr->lakh)	printf("%d lakh ",curr->lakh);
			if(curr->hajar)	printf("%d hajar ",curr->hajar);	
			if(curr->shata)	printf("%d shata ",curr->shata);
			if(curr!=head&&curr->kuti==0&&curr->lakh==0&&
			curr->hajar==0&&curr->shata==0) printf("kuti ");
		}
		if(e>0) printf("%d",e);
		printf("\n");
		kas++;
		popall();
	}
	return 0;
}
Jan
Guru
Posts: 1334
Joined: Wed Jun 22, 2005 10:58 pm
Location: Dhaka, Bangladesh
Contact:

Post by Jan »

Try the following case

Input:

Code: Select all

762952003918195
Output:

Code: Select all

   1. 7 kuti 62 lakh 95 hajar 2 shata kuti 39 lakh 18 hajar 1 shata 95
Hope it helps.
Ami ekhono shopno dekhi...
HomePage
kouco
New poster
Posts: 1
Joined: Fri Jan 26, 2007 6:29 pm

OMG~

Post by kouco »

Similiar with a poster mentioned before, I tested all the test cases as well as print my output to a txt file ensuring that there is no NUll or extra character output, can any experience programmer give me some insight so that I can get AC (T~T)"||

Code: Select all

#include <stdio.h>

void main(){
	char in[16];
	int i,l,p;
	char a;

	a=0;
	while(gets(in)){
		a++;
		
		while(in[0]=='0' && in[1]!=0){
			l=0;
			while(in[l]){
				in[l]=in[l+1];
				l++;
			}
		}
		
		i=l=0;
		while(in[i]){
			l++;
			i++;
		}
		printf("%4d. ",a);
		
		for(i=0;i<l;i++){
			p=l-i-1;
			if(p==0){
				if(l>2){
					if(in[i-1]!='0' && in[i]!='0'){
						printf(" %c%c",in[i-1],in[i]);
					}else if(in[i-1]!='0' && in[i]=='0'){
						printf(" %c%c",in[i-1],in[i]);
					}else if(in[i-1]=='0' && in[i]!='0'){
						printf(" %c",in[i]);
					}
				}else if(l==2){
					if(in[i-1]!='0' && in[i]!='0'){
						printf("%c%c",in[i-1],in[i]);
					}else if(in[i-1]!='0' && in[i]=='0'){
						printf("%c%c",in[i-1],in[i]);
					}else if(in[i-1]=='0'){
						printf("%c",in[i]);
					}
				}else{
					printf("%c",in[i]);
				}
			}

			if(p==2){
				if(l>3){
					if(in[i]!='0'){
						printf(" %c shata",in[i]);
					}
				}else{
					printf("%c shata",in[i]);
				}
			}
				
			if(p==3){
				if(l>5){
					if(in[i-1]!='0' && in[i]!='0'){
						printf(" %c%c hajar",in[i-1],in[i]);
					}else if(in[i-1]!='0' && in[i]=='0'){
						printf(" %c%c hajar",in[i-1],in[i]);
					}else if(in[i-1]=='0' && in[i]!='0'){
						printf(" %c hajar",in[i]);
					}
				}else if(l==5){
					if(in[i]!='0' && in[i-1]!='0'){
						printf("%c%c hajar",in[i-1],in[i]);
					}else if(in[i-1]!='0' && in[i]=='0'){
						printf("%c%c hajar",in[i-1],in[i]);
					}else if(in[i-1]=='0'){
						printf("%c hajar",in[i]);
					}
				}else{
					if(in[i]!='0'){
						printf("%c hajar",in[i]);
					}
				}
			}

			if(p==5){
				if(l>7){
					if(in[i-1]!='0' && in[i]!='0'){
						printf(" %c%c lakh",in[i-1],in[i]);
					}else if(in[i-1]!='0' && in[i]=='0'){
						printf(" %c%c lakh",in[i-1],in[i]);
					}else if(in[i-1]=='0' && in[i]!='0'){
						printf(" %c lakh",in[i]);
					}
				}else if(l==7){
					if(in[i-1]!='0' && in[i]!='0'){
						printf("%c%c lakh",in[i-1],in[i]);
					}else if(in[i-1]!='0' && in[i]=='0'){
						printf("%c%c lakh",in[i-1],in[i]);
					}else if(in[i-1]=='0'){
						printf("%c lakh",in[i]);
					}
				}else{
					if(in[i]!='0'){
						printf("%c lakh",in[i]);
					}
				}
			}

			if(p==7){
				if(l>9){
					if(in[i-1]!='0' && in[i]!='0'){
						printf(" %c%c kuti",in[i-1],in[i]);
					}else if(in[i-1]!='0' && in[i]=='0'){
						printf(" %c%c kuti",in[i-1],in[i]);
					}else if(in[i-1]=='0' && in[i]!='0'){
						printf(" %c kuti",in[i]);
					}else{
						printf(" kuti");
					}
				}else if(l==9){
					if(in[i-1]!='0' && in[i]!='0'){
						printf("%c%c kuti",in[i-1],in[i]);
					}else if(in[i-1]!='0' && in[i]=='0'){
						printf("%c%c kuti",in[i-1],in[i]);
					}else if(in[i-1]=='0'){
						printf("%c kuti",in[i]);
					}else{
						printf(" kuti");
					}
				}else{
					printf("%c kuti",in[i]);
				}
			}

			if(p==9){
				if(l>10){
					if(in[i]!='0'){
						printf(" %c shata",in[i]);
					}
				}else{
					if(in[i-1]!='0'){
						printf("%c shata",in[i]);
					}
				}
			}
			
			if(p==10){
				if(l>12){
					if(in[i-1]!='0' && in[i]!='0'){
						printf(" %c%c hajar",in[i-1],in[i]);
					}else if(in[i-1]!='0' && in[i]=='0'){
						printf(" %c%c hajar",in[i-1],in[i]);
					}else if(in[i-1]=='0' && in[i]!='0'){
						printf(" %c hajar",in[i]);
					}
				}else if(l==12){
					if(in[i-1]!='0' && in[i]!='0'){
						printf("%c%c hajar",in[i-1],in[i]);
					}else if(in[i-1]!='0' && in[i]=='0'){
						printf("%c%c hajar",in[i-1],in[i]);
					}else if(in[i-1]=='0'){
						printf("%c hajar",in[i]);
					}
				}else{
					if(in[i]!='0'){
						printf("%c hajar",in[i]);
					}
				}
			}

			if(p==12){
				if(l>14){
					if(in[i-1]!='0' && in[i]!='0'){
						printf(" %c%c lakh",in[i-1],in[i]);
					}else if(in[i-1]!='0' && in[i]=='0'){
						printf(" %c%c lakh",in[i-1],in[i]);
					}else if(in[i-1]=='0' && in[i]!='0'){
						printf(" %c lakh",in[i]);
					}
				}else if(l==14){
					if(in[i-1]!='0' && in[i]!='0'){
						printf("%c%c lakh",in[i-1],in[i]);
					}else if(in[i-1]!='0' && in[i]=='0'){
						printf("%c%c lakh",in[i-1],in[i]);
					}else if(in[i-1]=='0'){
						printf("%c lakh",in[i]);
					}
				}else{
					if(in[i]!='0'){
						printf("%c lakh",in[i]);
					}
				}

			}
			
			if(p==14){
				if(in[i]!='0'){
					printf("%c kuti",in[i]);
				}
			}
		}
		printf("\n");
	}
}
algoJo
New poster
Posts: 37
Joined: Sun Dec 17, 2006 9:02 am

TLE why???

Post by algoJo »

Hi guys, I still confused what make my code get TLE
can somebody give me some hints...
thanks before....

Code: Select all

Accepted
Last edited by algoJo on Tue Mar 27, 2007 3:04 am, edited 1 time in total.
ranban282
New poster
Posts: 37
Joined: Tue May 02, 2006 1:01 pm
Contact:

Why WA??

Post by ranban282 »

I have no clue as to why i get wa. Could anyone give me test cases for this problem?
Thanks

Code: Select all

#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<list>
#include<queue>
#include<cctype>
#include<stack>
#include<map>
#include<set>
using namespace std;

void convert(long long n)
{
	int flag=0;
	if(n>100000)
	{printf("%Ld lakh",n/100000);flag=1;}
	if((n%100000)/1000>0)
	{
		printf("%s",flag?" ":"");
		printf("%Ld hajar",(n%100000)/1000);
		flag=1;
	}
	if((n%1000)/100>0)
	{
		printf("%s",flag?" ":"");
		printf("%Ld shata",(n%1000)/100);
		flag=1;
	}
	if(n%100>0)
	{
		printf("%s",flag?" ":"");
		printf("%Ld",(n%100));
	}

}
int main()
{
	long long n;
	int count=0;	
	while(cin>>n)
	{
		count++;
		printf("%4d. ",count);
		int flag=0;
		
		if((n/10000000)/10000000)
		{
			convert((n/10000000)/10000000);
			printf(" kuti");
			flag=1;
		}
		if(n/10000000)
		{
			if(flag &&((n%((long long)10000000*(long long)10000000))/10000000 ))
				printf(" ");
			convert((n%((long long)10000000*(long long)10000000))/10000000);
			printf(" kuti");
			flag=1;
		}
		if(n%10000000)
		{
			if(flag)
			printf(" ");

			convert(n%10000000);
		}
		if(n==0)
			printf("0");
		printf("\n");

	}
	return 0;
}
Post Reply

Return to “Volume 101 (10100-10199)”