Hello
I trying to use readkey but it always get compiler error on online-judge
Microsoft(R) Windows DOS
(C)Copyright Microsoft Corp 1990-2001.
C:\PASCAL>fpc -dONLINE_JUDGE -Sd testasso.pas
Free Pascal Compiler version 2.0.4 [2006/08/21] for i386
Copyright (c) 1993-2006 by Florian Klaempfl
Target OS: Win32 for i386
Compiling testasso.pas
Linking testasso.exe
49 Lines compiled, 1.2 sec
C:\PASCAL>
But as you can see there is no problem with compiling
Coundt I use readkey function using 'uses CRT' ??
How could I substitute readkey function for another?
please helpme
Uses Crt to use Readkey function ----> compiler error
Moderator: Board moderators
-
- New poster
- Posts: 4
- Joined: Sat Nov 04, 2006 5:40 am
-
- New poster
- Posts: 4
- Joined: Sat Nov 04, 2006 5:40 am
Problem is about input!
Var
Num,I,J : Real;
Length,Maior,contador : Word;
Begin
While Not Eof(Input) Do
Begin
Readln(I,J);
Write(I:1:0,' ',J:1:0,' ');
Maior := 0;
For Contador := Trunc(J) Downto Trunc(I) Do
Begin
Length :=1;
Num := Contador;
While Num <> 1 Do
If (trunc(Num) mod 2) = 0 Then
Begin
Num := Num / 2;
Length := Length + 1;
End
Else
Begin
Num := (Num * 3) + 1;
Length := Length+1;
End;
If Maior < Length Then
Maior := Length;
End;
Writeln(Maior);
End;
End.
This is my code to problem 100
but always i got TIME limit EXCEDEED!!
What is problem with my code?
Num,I,J : Real;
Length,Maior,contador : Word;
Begin
While Not Eof(Input) Do
Begin
Readln(I,J);
Write(I:1:0,' ',J:1:0,' ');
Maior := 0;
For Contador := Trunc(J) Downto Trunc(I) Do
Begin
Length :=1;
Num := Contador;
While Num <> 1 Do
If (trunc(Num) mod 2) = 0 Then
Begin
Num := Num / 2;
Length := Length + 1;
End
Else
Begin
Num := (Num * 3) + 1;
Length := Length+1;
End;
If Maior < Length Then
Maior := Length;
End;
Writeln(Maior);
End;
End.
This is my code to problem 100
but always i got TIME limit EXCEDEED!!
What is problem with my code?
Re: Problem is about input!
I wonder y u got a TLE rather than RE - the maximum allowed integer is 999999, yet the range of Word is 0-65536.leeyeanhoo wrote: This is my code to problem 100
but always i got TIME limit EXCEDEED!!
What is problem with my code?
Also, y bother reading numbers in Real and trunc them in calculations?
Use LongInt directly should help.