619 - Numerically Speaking

All about problems in Volume 6. 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
suman
New poster
Posts: 45
Joined: Fri Oct 19, 2001 2:00 am
Contact:

Post by suman »

I used
Input
-----
009
aa
27
1
10
0
26
z
78
bz
52
az
104
cz
728
aaz
29697684282993
transcendental
28011622636823854456520
computationally
zzzzzzzzzzzzzzzzzzzz
157118051752
eclectic
perspective
35672211599026729
a
c
b
z
*

and output
----------
i 009
aa 27
aa 27
a 1
j 10
z 0
z 26
z 26
bz 78
bz 78
az 52
az 52
cz 104
cz 104
aaz 728
aaz 728
elementary 29,697,684,282,993
transcendental 51,346,529,199,396,181,750
prestidigitation 28,011,622,636,823,854,456,520
computationally 232,049,592,627,851,629,097
zzzzzzzzzzzzzzzzzzzz 20,725,274,851,017,785,518,433,805,270
snowfall 157,118,051,752
eclectic 41,230,726,085
perspective 2,289,737,544,193,013
irrationally 35,672,211,599,026,729
a 1
c 3
b 2
z 26


But still wa


Please help
- Suman
suman
New poster
Posts: 45
Joined: Fri Oct 19, 2001 2:00 am
Contact:

Post by suman »

Pervious message was reformated by the board
trying this
output
------

i 009
aa 27
aa 27
a 1
j 10
z 0
z 26
z 26
bz 78
bz 78
az 52
az 52
cz 104
cz 104
aaz 728
aaz 728
elementary 29,697,684,282,993
transcendental 51,346,529,199,396,181,750
prestidigitation 28,011,622,636,823,854,456,520
computationally 232,049,592,627,851,629,097
zzzzzzzzzzzzzzzzzzzz 20,725,274,851,017,785,518,433,805,270
snowfall 157,118,051,752
eclectic 41,230,726,085
perspective 2,289,737,544,193,013
irrationally 35,672,211,599,026,729
a 1
c 3
b 2
z 26
Ivan Golubev
Experienced poster
Posts: 167
Joined: Fri Oct 19, 2001 2:00 am
Location: Saint Petersburg, Russia

Post by Ivan Golubev »

I've also got WA on this problem after rejudgement. And I suspect that there something wrong with input. Can somebody comment it?
Sherman MXF
New poster
Posts: 14
Joined: Sun May 26, 2002 1:54 pm
Location: China

Post by Sherman MXF »

I got Accepted. I think there is no leading zeros in the input.
Good luck.
Ivan Golubev
Experienced poster
Posts: 167
Joined: Fri Oct 19, 2001 2:00 am
Location: Saint Petersburg, Russia

Post by Ivan Golubev »

There was a capital letter(s) in input. That was fixed and rejudged several monthes ago, now everything OK.
ffkre
New poster
Posts: 3
Joined: Tue Feb 11, 2003 4:13 pm

619.....plz....help........

Post by ffkre »

how can i get the input 20,725,274,851,017,785,518,433,805,270?
i can't get it by long long........
any data type can do this?
thx~
Dominik Michniewski
Guru
Posts: 834
Joined: Wed May 29, 2002 4:11 pm
Location: Wroclaw, Poland
Contact:

Post by Dominik Michniewski »

any type of data doesn't handle such big input value ....
you must try to write your own version of BigInteger :)) as strings mabe ;-)

Dominik
If you really want to get Accepted, try to think about possible, and after that - about impossible ... and you'll get, what you want ....
Born from ashes - restarting counter of problems (800+ solved problems)
ffkre
New poster
Posts: 3
Joined: Tue Feb 11, 2003 4:13 pm

Post by ffkre »

how can declare the own strcuture ?
can u tell me how to do it?
TWEmp
New poster
Posts: 7
Joined: Tue Jan 21, 2003 4:52 am
Location: Hong Kong
Contact:

Re: 619

Post by TWEmp »

ffkre wrote:how can declare the own strcuture ?
can u tell me how to do it?
Strings are character arrays in C. This makes
manipulation on extremely big integers by string
easier.

For this question, you can consider the steps of
long division which helps the whole number handling
a lot.

Meanwhile, I get accepted HERE for this question but I get
Array Index Out Of Bound Error somewhere else. I'd like
to obtain some useful test cases in order to tackle my
problem.
steve4760
New poster
Posts: 1
Joined: Tue May 11, 2004 3:11 pm

619---Wrong Answer

Post by steve4760 »

Code: Select all

/* This is my code,I got WA many times.Please help me!!! */
#include<stdio.h>
#include<string.h>
#include<ctype.h>
int diff(long matrix1[11],long matrix2[11])
{
	long i,j;
	i=10;
	while(matrix1[i]==0)
		i--;
	j=10;
	while(matrix2[j]==0)
		j--;
	if(i>j)
		return 0;
	else if(i==j)
	{
		for(;i>=0;i--)
		{
			if(matrix1[i]>matrix2[i])
			{
				return 0;
				break;
			}
			else if(matrix1[i]<matrix2[i])
			{
				return 1;
				break;
			}
		}
	}
	else
		return 1;
}
void main()
{
	char input[50];
	long carry,count,inputl,i,j,k,num[11],tmp1[11],ts[21][11]={0},limit[21][11]={0};
	ts[0][0]=limit[0][0]=1;
	for(i=1;i<21;i++)
	{
		carry=j=0;
		while(ts[i-1][j]!=0)
		{
			ts[i][j]=ts[i-1][j]*26+carry;
			carry=ts[i][j]/1000;
			ts[i][j]=ts[i][j]%1000;
			j++;
		}
		ts[i][j]+=carry;
	}
	for(i=1;i<21;i++)
	{
		carry=j=0;
		while(ts[i][j]!=0)
		{
			limit[i][j]=limit[i-1][j]+ts[i][j]+carry;
			carry=limit[i][j]/1000;
			limit[i][j]=limit[i][j]%1000;
			j++;
		}
		limit[i][j]+=carry;
	}
	while(scanf(" %s",input)==1)
	{
		for(i=0;i<11;i++)
			num[i]=tmp1[i]=0;
		if(input[0]=='*')
			break;
		else if(isalpha(input[0])!=0)
		{
			inputl=strlen(input);
			for(i=0;i<inputl;i++)
			{
				carry=j=0;
				while(ts[inputl-i-1][j]!=0 || num[j]!=0)
				{
					if(input[i]>='a' && input[i]<='z')
						num[j]+=ts[inputl-i-1][j]*(input[i]-'a'+1)+carry;
					else if(input[i]>='A' && input[i]<='Z')
						num[j]+=ts[inputl-i-1][j]*(input[i]-'A'+1)+carry;
					carry=num[j]/1000;
					num[j]=num[j]%1000;
					j++;
				}
				num[j]+=carry;
			}
		}
		else
		{
			inputl=strlen(input);
			for(i=0;i<inputl;i++)
			{
				num[0]=tmp1[0]=num[0]*10+(input[i]-'0');
				if(num[0]>=1000)
				{
					carry=num[0]/1000;
					num[0]=tmp1[0]=num[0]%1000;
				}
				j=1;
				while(j<=i/3)
				{
					num[j]=tmp1[j]=num[j]*10+carry;
					carry=num[j]/1000;
					num[j]=tmp1[j]=num[j]%1000;
					j++;
				}
			}
			i=20;
			while(diff(tmp1,limit[i])!=0)
				i--;
			for(k=0;i>=0;i--,k++)
			{
				count=0;
				while(diff(tmp1,limit[i])==0)
				{
					for(j=0;j<11;j++)
					{
						tmp1[j]=tmp1[j]-ts[i][j];
						if(tmp1[j]<0)
						{
							tmp1[j+1]-=1;
							tmp1[j]+=1000;
						}
					}
					count++;
				}
				input[k]=count-1+'a';
			}
			input[k]='\0';
			inputl=strlen(input);
		}
		printf("%s",input);
		for(i=inputl+1;i<23;i++)
			printf(" ");
		i=10;
		while(num[i]==0)
			i--;
		printf("%ld",num[i]);
		if(i>0)
			printf(",");
		for(i=i-1;i>=0;i--)
		{
			if(num[i]<10)
				printf("00%ld",num[i]);
			else if(num[i]<100)
				printf("0%ld",num[i]);
			else
				printf("%ld",num[i]);
			if(i!=0)
				printf(",");
		}
		printf("\n");
	}
}
oja
New poster
Posts: 11
Joined: Fri Apr 24, 2015 5:34 pm

Re: 619 - Numerically Speaking

Post by oja »

why am i getting RE? I tried udebug with both upper and lower bound inputs and my code works..

Code: Select all

got AC, code deleted
EDIT: I got multiple REs just because the name of the main class isn't "Main"!!
Post Reply

Return to “Volume 6 (600-699)”