Page 2 of 4
Posted: Tue Feb 03, 2004 10:24 am
by titid_gede
i submitted your code without any changes and got AC. so what's your problem?
-titid-
Posted: Tue Feb 03, 2004 11:21 am
by WR
My problem is that the OJ returns WA!!!
If the code is ok, then what could be the reason for this?
It compiles ok so it can't be the mail program.
I will just submit the code again and see what happens this time.
Thanks for the 2nd time today!!!
Posted: Tue Feb 03, 2004 1:25 pm
by WR
Hi titid,
Well it's a WA again!!!
Your program has not solved the problem. It ran during 1.273 seconds.
I didn't change anything.
How come you got the program accepted?
Posted: Tue Feb 03, 2004 1:52 pm
by titid_gede
Posted: Tue Feb 03, 2004 2:43 pm
by WR
Ok, I used submit-o-matic and the statistics show that the
program now has been accepted!
So indeed the mail program has been the culprit.
Switching to submit-o-matic from now on!
Thanks again titid!
Posted: Mon Jun 14, 2004 4:59 pm
by Sarwar
I am getting worng answer. where is the problem??
please help me.........
[cpp]
#include<stdio.h>
#include<string.h>
#include<math.h>
#define MAX 100
long DEC;
char Other[MAX];
char Insert_Char(long base,long mod)
{
long i;
char C = 'A';
for(i = 0; i < base - 10; i++)
if(mod == 10+i) return (char) (C+i);
return '0';
}
void To_Desimal(char *NUM, long base)
{
long i,ins,l,len;
l = len = strlen(NUM) - 1;
DEC = 0;
for(i = 0; i <= len ; i++)
{
if(NUM == 'A') ins = 10;
else if( NUM == 'B') ins = 11;
else if( NUM == 'C') ins = 12;
else if( NUM == 'D') ins = 13;
else if( NUM == 'E') ins = 14;
else if( NUM == 'F') ins = 15;
else ins = NUM - '0';
DEC = DEC + ins * pow(base,l);
l--;
}
}
void From_Desimal(long base)
{
long i,mod,len,j;
char temp[MAX];
long dec;
dec = DEC;
for(i = 0; dec!=0;i++ )
{
mod = dec % base;
if(mod >= 10)
temp = Insert_Char(base,mod);
else temp = mod + '0';
dec = dec / base;
}
temp = NULL;
len = strlen(temp)-1;
j = 0;
for(i = len; i >= 0; i-- )
Other[j++]=temp[i];
Other[j] = NULL;
}
int main()
{
int i,minus;
long b1,b2,flag;
char NUM[MAX];
//freopen("c:\\out.txt","w",stdout);
while( scanf("%s %ld%ld",NUM,&b1,&b2)==3)
{
flag = 0;
minus = 0;
for(i = 0; NUM[i]!=NULL; i++)
if(NUM[i] != '0'){ flag=1;break;}
if(flag == 0) {printf(" 0\n");continue;}
else if(b2 == 10 )
{
To_Desimal(NUM,b1);
if(DEC > 9999999){printf(" ERROR\n");continue;}
printf("%7lld\n",DEC);
}
else if(b1 == 10)
{
sscanf(NUM,"%lld",&DEC);
From_Desimal(b2);
if(strlen(Other) > 7){ printf(" ERROR\n");continue;}
printf("%7s\n",Other);
}
else
{
To_Desimal(NUM,b1);
From_Desimal(b2);
if(strlen(Other) > 7){printf(" ERROR\n");continue;}
printf("%7s\n",Other);
}
}
return 0;
}
[/cpp]
Posted: Mon Jun 14, 2004 5:48 pm
by UFP2161
There is no input for this problem. You are to find and output all sets with a <= 200.
386 what is wrong
Posted: Thu Nov 18, 2004 6:55 am
by randomtaiwanese
[java]for(int i=6;i<=200;i++)
{
for(int j=2;j<i;j++)
{
for(int k=2;k<=j;k++)
{
for(int l=2;l<=k;l++)
{
if(i*i*i==(k*k*k+j*j*j+l*l*l))
{
System.out.println("Cube = "+i+", Triple = ("+l+","+k+","+j+")");
}
}
}
}
}[/java]
Getting 0:00 time for problem 386
Posted: Tue Apr 19, 2005 1:47 pm
by rajeshr92
I would like to know how get 00:00 time for problem 386.I used the following code and
got time of 0:01:614.Though it got AC i would like to optimize more
#include <stdio.h>
int main()
{
int a,b,c,d;
for(a=6;a<=200;a++)
for(b=2;b<a;b++)
for(c=b;c<a;c++)
for(d=c;d<a;d++)
if(a*a*a==(b*b*b+c*c*c+d*d*d))
{
printf("Cube = %d, Triple = (%d,%d,%d)\n",a,b,c,d);
}
return 0;
}
Posted: Fri Apr 29, 2005 6:16 pm
by sahand
Hi,
I think most of those 0:00 for this problem are done using pre calculation.
Maybe even all of them!
Anyway, I think you can optimize your code a good amount in the following way. I could get it accepted in 0:00.980 which is not really good, but is still better.
Code: Select all
#include <stdio.h>
int main()
{
int a,b,c,d;
int acube,bcube,ccube,bplusc;
for(a=6;a<=200;a++)
{
acube=a*a*a;
for(b=2;b<a;b++)
{
bcube=b*b*b;
for(c=b;c<a;c++)
{
ccube=c*c*c;
bplusc=bcube+ccube;
for(d=c;d<a;d++)
{
if(acube==(bplusc+d*d*d))
{
printf("Cube = %d, Triple = (%d,%d,%d)\n",a,b,c,d);
}
}
}
}
}
return 0;
}
The judgieing machine seems wrong
Posted: Sun Jun 26, 2005 2:47 pm
by Md. Aftabuddin
Dear Sir,
I am a new commer I solved the question no 386 and submitted only to get wrong answer.
But my solution is right and running within the time limit. Further more the output given in the question is itself wrong. it is not showing the line
Cube = 9, Triple = (1,6,8 )
but 9*9*9=1*1*1 +6*6*6+ 8*8*8
So the question must be corrected.
I also submitted question no 834 but your judging system says it as wrong.
Also I took part in the online programming contest on 25/6/2005 I solved the question B only but your online judge says it as wrong answer .
There must be some thing wrong in the judgeing system
Md. Aftabuddin
Posted: Sun Jun 26, 2005 3:21 pm
by Adrian Kuegel
Please make sure that you understand the problem. I believe you that you think you solved the problems right, however you will always get WA if you solved another problem than was posed.
For problem 386, please consider that you have to find values a,b,c > 1 !!!
I suggest you read the problem descriptions of that other problems again, maybe you also overlooked something.
Posted: Mon Jun 27, 2005 11:59 am
by misof
Also, it is not wise to post your whole ID, you are supposed to keep the two letters at the end secret. (Anyone that knows them may submit solutions using your account.) I suggest that you edit your post and delete them before anyone can misuse this information.
Posted: Thu May 04, 2006 3:28 pm
by alexg
I got 0.018 by using a hash table. I'll leave you to work out how a hashtable could help in this situation.
386 wa, it seems ok but......
Posted: Mon May 29, 2006 7:56 pm
by ayeshapakhi
please show me the mistake...
thanks.........