495 - Fibonacci Freeze
Moderator: Board moderators
u must use big integer to solve this problem...
try these:
INPUT:
OUTPUT:
try these:
INPUT:
Code: Select all
5000
Code: Select all
The Fibonacci number for 5000 is 3878968454388325633701916308325905312082127714646245106160597214895550139044037097010822916462210669479293452858882973813483102008954982940361430156911478938364216563944106910214505634133706558656238254656700712525929903854933813928836378347518908762970712033337052923107693008518093849801803847813996748881765554653788291644268912980384613778969021502293082475666346224923071883324803280375039130352903304505842701147635242270210934637699104006714174883298422891491273104054328753298044273676822977244987749874555691907703880637046832794811358973739993110106219308149018570815397854379195305617510761053075688783766033667355445258844886241619210553457493675897849027988234351023599844663934853256411952221859563060475364645470760330902420806382584929156452876291575759142343809142302917491088984155209854432486594079793571316841692868039545309545388698114665082066862897420639323438488465240988742395873801976993820317174208932265468879364002630797780058759129671389634214252579116872755600360311370547754724604639987588046985178408674382863125
My output is correct, but in server CE (compile error).
"Compile error". WHY?
Please, help.
"Compile error". WHY?
Code: Select all
CODE REMOVE
Thanks Jan (for help me with 1st error "compile error").
Last edited by Nakar on Wed Apr 25, 2007 9:22 pm, edited 2 times in total.
Replace
with
Code: Select all
int borrarint(bigint *a)
Code: Select all
void borrarint(bigint *a)
Ami ekhono shopno dekhi...
HomePage
HomePage
with the fo.llowing code i got a compile error which is running perfectly on my comp.
import java.io.*;
import java.util.*;
import java.math.*;
class Main{
private static BufferedReader stdin =
new BufferedReader( new InputStreamReader( System.in ) );
public static void main (String args[])
{
Main myWork = new Main();
myWork.Begin();
}
void Begin(){
int j,number=0;
String input=null;
while (true) {
try{
input = stdin.readLine();
number = Integer.parseInt( input );
}catch(Exception e){
System.exit(0);
}
BigInteger a = new BigInteger("0");
BigInteger b = new BigInteger("1");
BigInteger c = new BigInteger("0");
for(j=0;j<number;j++)
{
a=b;b=c;
c=a.add(b);
}
System.out.println("The Fibonacci number for "+number+" is "+c);
}
}
}
Here are the compiler error messages:
05593703_24.java:3: Can't find default package `java.math'. Check the
CLASSPATH environment variable and the access to the archives.
1 error
someone plz help.
import java.io.*;
import java.util.*;
import java.math.*;
class Main{
private static BufferedReader stdin =
new BufferedReader( new InputStreamReader( System.in ) );
public static void main (String args[])
{
Main myWork = new Main();
myWork.Begin();
}
void Begin(){
int j,number=0;
String input=null;
while (true) {
try{
input = stdin.readLine();
number = Integer.parseInt( input );
}catch(Exception e){
System.exit(0);
}
BigInteger a = new BigInteger("0");
BigInteger b = new BigInteger("1");
BigInteger c = new BigInteger("0");
for(j=0;j<number;j++)
{
a=b;b=c;
c=a.add(b);
}
System.out.println("The Fibonacci number for "+number+" is "+c);
}
}
}
Here are the compiler error messages:
05593703_24.java:3: Can't find default package `java.math'. Check the
CLASSPATH environment variable and the access to the archives.
1 error
someone plz help.
g++: Internal compiler error: program as got fatal signal 25
I sumitted my code by it gave me CE with error:
g++: Internal compiler error: program as got fatal signal 25
Huh? Signal 25?
Can somebody please help me?
Any help is appreciated^^
g++: Internal compiler error: program as got fatal signal 25
Huh? Signal 25?
Can somebody please help me?
Any help is appreciated^^
Code: Select all
Code removed after accepted with mf's help, thanks!!!
Last edited by gba356 on Sat Jun 16, 2007 1:19 pm, edited 1 time in total.
When you use initialized arrays like this:
the compiler might put the array in the initialized data section, and as a result produce an executable file of size about 100Mb of mostly zero bytes. Probably that's too big for some compiler's module and it crashes with signal 25 (SIGXFSZ, File size limit exceeded).
If you don't initialize it, compiler will put the array in uninitialized data section, memory for which will be allocated at run-time, and then filled with zeros, too - so don't bother initializing globals with 0s.
Anyway, default memory limit for programs is 32Mb at this judge, so your program won't be accepted.
Code: Select all
#define N 5002
int fab[N][N]={{0}};
If you don't initialize it, compiler will put the array in uninitialized data section, memory for which will be allocated at run-time, and then filled with zeros, too - so don't bother initializing globals with 0s.
Anyway, default memory limit for programs is 32Mb at this judge, so your program won't be accepted.
1045 digits.newton wrote:how much digits the 5000th fibonacci number takes??
I forgot completely.newton wrote:what is urs minimum time and memory to solve it??
Nobody has solved it in 0.000 seconds.newton wrote:how is it possible to solve it in 0.00 sec and min mem??
Ami ekhono shopno dekhi...
HomePage
HomePage
-
- Experienced poster
- Posts: 109
- Joined: Sat Jun 23, 2007 9:53 pm
- Location: Brest, BELARUS
- Contact:
There is something unusual with this problem. I created an input file for all numbers between 0 and 5000 inclusive and ran my solution for it. On my PC it worked ~3 seconds. But Judge says it's TLE.
But I managed to get AC (thanking little joey). (His) Hint for PAS programmers: don't use write to output. Output everything in ansistring and then just writeln it.
But I managed to get AC (thanking little joey). (His) Hint for PAS programmers: don't use write to output. Output everything in ansistring and then just writeln it.
Now I lay me down to sleep...
my profile
my profile
I have written the following code for this problem:
I have tested using the test cases in this thread and found myself correct. However, I submitted to the judge and it says WA. what's wrong with my code?
Thanks.
Code: Select all
-- Deleted --
Thanks.
Last edited by peterkwan on Sun Nov 04, 2007 8:42 am, edited 1 time in total.
Try this case..
See the result of '4997'
I don't know why this is happening..
Code: Select all
5000
4998
4997
I don't know why this is happening..