619 - Numerically Speaking
Moderator: Board moderators
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
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
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
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
-
- Experienced poster
- Posts: 167
- Joined: Fri Oct 19, 2001 2:00 am
- Location: Saint Petersburg, Russia
-
- New poster
- Posts: 14
- Joined: Sun May 26, 2002 1:54 pm
- Location: China
-
- Experienced poster
- Posts: 167
- Joined: Fri Oct 19, 2001 2:00 am
- Location: Saint Petersburg, Russia
619.....plz....help........
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~
i can't get it by long long........
any data type can do this?
thx~
-
- Guru
- Posts: 834
- Joined: Wed May 29, 2002 4:11 pm
- Location: Wroclaw, Poland
- Contact:
any type of data doesn't handle such big input value ....
you must try to write your own version of BigInteger
) as strings mabe ![;-)](./images/smilies/icon_wink.gif)
Dominik
you must try to write your own version of BigInteger
![:)](./images/smilies/icon_smile.gif)
![;-)](./images/smilies/icon_wink.gif)
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)
Born from ashes - restarting counter of problems (800+ solved problems)
Re: 619
Strings are character arrays in C. This makesffkre wrote:how can declare the own strcuture ?
can u tell me how to do it?
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.
619---Wrong Answer
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");
}
}
Re: 619 - Numerically Speaking
why am i getting RE? I tried udebug with both upper and lower bound inputs and my code works..
EDIT: I got multiple REs just because the name of the main class isn't "Main"!!
Code: Select all
got AC, code deleted