Page 3 of 19

Posted: Fri Jun 28, 2002 10:36 am
by Picard
what about "1 100" ?

Posted: Fri Jun 28, 2002 2:17 pm
by Archangel
I had rewrote my program to let the output be "0 n" when any input of the form "1 n", but I still got wrong answer... :cry:
Did I still miss something?...Thanks!!

Posted: Fri Jun 28, 2002 2:25 pm
by Revenger
Picard write:
what about "1 100" ?
May be I am wrong, but ...
  • 1.The smallest cats have a heigth one, i.e. 1
  • 2.If Initial cat have a heigth one then there is only one cat
So I think, that there is no a such test

Posted: Fri Jun 28, 2002 2:35 pm
by Revenger
How can I get floating point operation error? If there are very big numbers in input then I really get floating point operation error. But what should I do in this case? Can you help me?

Posted: Fri Jun 28, 2002 2:40 pm
by Revenger
But there is a such test in input :(
What should I output?

Posted: Fri Jun 28, 2002 2:42 pm
by Picard
you are right. "1 100" is invalid. but there is a "1 1" in the judge's input, and there is a "2 1" too (which probably fails Archangel's solution).

Posted: Fri Jun 28, 2002 4:09 pm
by Archangel
I modified my code again...to let the output of "2 1" to be "1 3" and "1 1" to be "0 1",but still wrong answer again...>.<

Posted: Sat Jun 29, 2002 10:17 am
by Revenger
Hi, Archangel!

It's very strange that your program gets WA. I have found error in my program in test "2 1" Try this test:

Code: Select all

1024 243
The correct output is:

Code: Select all

121 3367

Posted: Sat Jun 29, 2002 6:03 pm
by Archangel
Thank you~^^...but for the input "1024 243", my program gave me the right answer..."121 3367".

Will the input number out of the range of "unsigned Integer" be possible(21474836648~-21474836647)?? (because I declear my variable as Integer type)

Posted: Sat Jun 29, 2002 6:17 pm
by 10153EN
I think nope.

I just declare the variables to be int and it's OK. :D

107 - The Cat in the Hat

Posted: Tue Jul 09, 2002 10:50 am
by limon limon
///this code give tlme limit exceeds error




#include<stdio.h>
#include<iostream.h>

#include<math.h>




void main()
{
unsigned long n,h,f,x=1,hi,nw,test,total,power,stack,count;
float p,nwf,hif;






count=-1;
for(;x==1; ){
f=0;
count++;
scanf("%lu%lu",&h,&n) ;

test=1;
if(n==0&&h==0)
x=0;
else
{
while(test==1)
{
f++;
p=f;

nwf=pow(n,1.0/p);
//hif=pow(h,1.0/p);

nw=nwf;

if(nwf-nw>0.5)
nw++;

hi=nw+1;



if(pow(nw,f)==n)
if (pow(hi,f)==h)
{

total=0;

stack=n;
for(power=0;power<f;power++)
{
total=total+pow(nw,power);

stack=stack+h*pow(nw,power);
h=h/hi;


}

if(count>0)
cout<<"\n";
cout<<total<<" "<<stack;



test=0;
}







}



}


}

}

WA :107 why??

Posted: Wed Jul 17, 2002 5:10 pm
by galois_godel
@BEGIN_OF_SOURCE_CODE
program P107(input,output);

var h,num,n,k,freenum,sumheight:integer;
r,rnum:real;
function getn(h,num:integer):integer;
var
i:integer;
c:real;
begin
if (h-num)=1 then
begin
getn:=num;
exit;
end;
i:=1;
c:=ln(num)*ln(i+1)-ln(h)*ln(i);
while abs(c)>0.00000001 do
begin
i:=i+1;
c:=ln(num)*ln(i+1)-ln(h)*ln(i);
end;
getn:=i;
end;
begin
// Insert user code here
while not eof(input) do
begin
readln(h,num);
if (h=0)and(num=0)then break;
if h=1 then
writeln(1,' ',0)
else
begin
if num=1 then
begin
k:=round(ln(h)/ln(2));
writeln(k,' ',2*h-1);
end
else
begin
n:=getn(h,num);
r:=h;rnum:=num;
r:=r*(n+1)-rnum*n;
writeln((num-1)div(n-1),' ',r:0:0);
end;
end;
end;


end.
@END_OF_SOURCE_CODE

who can give some sample input and sample output for 107

Posted: Sat Jul 20, 2002 1:51 pm
by galois_godel
who can give some sample input and sample output for problem 107
because I am unable to know why my answer is wrong


program P107(input,output);

var h,num,n,k,freenum,sumheight:integer;
r,rnum:real;
function getn(h,num:integer):integer;
var
i:integer;
c:real;
begin
if (h-num)=1 then
begin
getn:=num;
exit;
end;
i:=1;
c:=ln(num)*ln(i+1)-ln(h)*ln(i);
while abs(c)>0.00000001 do
begin
i:=i+1;
c:=ln(num)*ln(i+1)-ln(h)*ln(i);
end;
getn:=i;
end;
begin
// Insert user code here
while not eof(input) do
begin
readln(h,num);
if (h=0)and(num=0)then break;
if h=1 then
writeln(1,' ',0)
else
begin
if num=1 then
begin
k:=round(ln(h)/ln(2));
writeln(k,' ',2*h-1);
end
else
begin
n:=getn(h,num);
r:=h;rnum:=num;
r:=r*(n+1)-rnum*n;
writeln((num-1)div(n-1),' ',r:0:0);
end;
end;
end;


end.

Posted: Sat Jul 20, 2002 9:41 pm
by soyoja
Use this sample. :)
( This test case is not mine. )


Input

371293 248832
11 10
1 1
1048576 59049
0 0

Output

22621 1840825
1 21
0 1
29524 4017157

Posted: Sat Jul 20, 2002 9:42 pm
by soyoja
Use this sample.
( This test case is not mine. )


Input

371293 248832
11 10
1 1
1048576 59049
0 0

Output

22621 1840825
1 21
0 1
29524 4017157