ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1086. Cryptography

Is there size limit of programs I submit???
Posted by Ivo 30 May 2001 01:19
I mean that my program is 1700 lines because in 1086 I
generate all simple numberes in an array. Is there some
other way to do so or do you have any idea why I receive
Compilation Error when the programs runs on my computer
prefectly???
hmm, i think .... (+)
Posted by Dinh Quang Hiep (mg9h@yahoo.com) 30 May 2001 02:52
you shouldn't solve the problem in that way. In this case,
generate the prime array is very fast and simple, use some
function to enshort your code and believe me, it won't make
your prog run slower (if so, just only 0.01s ;))

Good luck !

QH@

PS: btw, Tong Hop Vo Dich, you must know that ;)
I can't get it. What do you mean?
Posted by Ivo 31 May 2001 01:00
I can't get it. What do you mean?
Please explain it once again! Thanx
See about my program...
Posted by Ivo 31 May 2001 01:23
See what I do I make large const array and one other where
I keep the questions. It works perfectly on my computer but
the Judge says Compile Error! WHY??? Maybe it is because of
the 1670 lines of constant array???

const a:array[1..15000] of longint =
(2,3,5,7,11,13,17,19,23,
29,31,37,41,43,47,53,59,61,
67,71,73,79,83,89,97,101,103,
107,109,113,127,131,137,139,149,151,
157,163,167,173,179,181,191,193,197,
199,211,223,227,229,233,239,241,251,
257,263,269,271,277,281,283,293,307,
311,313,317,331,337,347,349,353,359,
367,373,379,383,389,397,401,409,419,
421,431,433,439,443,449,457,461,463,
467,479,487,491,499,503,509,521,523,
....
163327,163337,163351,163363,163367,163393,163403,163409,1634
11,
163417,163433,163469,163477,163481,163483,163487,163517,1635
43,
163561,163567,163573,163601,163613,163621,163627,163633,1636
37,
163643,163661,163673,163679,163697,163729,163733,163741,1637
53,
163771,163781,163789,163811,163819,163841);

var b:array[1..1000] of integer;
    br,k:integer;

begin
   readln(k); br:=0;
   for br:=1 to k do readln(b[br]);
   for br:=1 to k do writeln(a[b[br]]);
end.
Try this .....
Posted by Dinh Quang Hiep (mg9h@yahoo.com) 31 May 2001 22:21
in the main program, use don't have to use array b[], just
write this
const
a:
....

var
k, br, n : integer;
begin
  read(k);
  for br:=1 to k do
    begin
      read(N);
      writeln(a[N]);
    end;
end.

if u still get Compile error, that means the error is your
constant array. So, try to generate it from your function
include to your program, don't attach a const array to it
like yours now.
i.e :

var a : array [ 1..15000 ] of longint;
procedure generate_prime_array;
begin
...
{write your procedure to generate the array here}
...
end;

Good luck !

QH@
How can i generate the array in the procedure when I need more than 30 secs to do this job???
Posted by Ivo 1 Jun 2001 00:46
Do you mean to find another way to solve the problem
that is fast enought to get in the time?

How can I receive Compile Error when on my computer it runs
perfectly?

And last it's said in the task's text that you input number
k and k numbers. So your output is after you input the num.
What do you think?

Thanks !!!
Re: How can i generate the array in the procedure when I need more than 30 secs to do this job???
Posted by Jivko Ganev 1 Jun 2001 02:16
I think they have some limit on the max size of the program
that you can submit. Btw generating the prime array is
quite easy, if you have to check if x is prime then check
the numbers only from 2 to sqrt(x) if they are x's
divisors. Since you can generate the array bottom->up and
it doesn't make sense checking if composite numbers are x's
divisors, then you can use the already generated part
(discarding when you go > sqrt(x)) to check if it divides x.
If x is prime then you put it in the array. Btw you can
treat 2 as special case(it is the only prime that is even)
and try to add the numbers from 3-> using +2 as step.
i can do that, and you can too !
Posted by Dinh Quang Hiep (mg9h@yahoo.com) 1 Jun 2001 04:04
> Do you mean to find another way to solve the problem
> that is fast enought to get in the time?

Yes, i mean that !

> How can I receive Compile Error when on my computer it
runs
> perfectly?

Which Pascal language you use at home ? are u sure that it's
the same language and the same version with the one they use
in the judge ??? you know, there's a lot of diffrence
between some Pascal languages, and even if they are in the
same Pascal language, there's still some difference between
the versions. So that, your prog run perfectly in your
computer, it does not mean that it can't get compile error
in the judge !

> And last it's said in the task's text that you input
number
> k and k numbers. So your output is after you input the
num.

Do you know that "read(something)" that means "read(input,
something)", and so does write function. Here, you can
suppose that the word input in function read(input, ..) is a
variable of Text. Output in function write(output, ..) is
the same here. In the judge, you can image that, when you
read, that you read from a file, and you write, you are
writing to a file. That means it doesn't important you read
all the input before writing to output, or you read input,
then write output, read input again, .... The important
thing here is only the correctness of your output ! You can
determine what i said here is false or true by viewing the
FAQ page, in the end of page, about sending problem, they
test your output by run the command "test.exe
(output of user solution) (correct output)"

> What do you think?

So now my question for you is the same, "WHAT DO YOU THINK"
???

> Thanks !!!

You are welcome !

Good luck again ;)

QH@
btw, the server here is very fast, don't worry about the time when it's "only" 30s ;)
Posted by Dinh Quang Hiep (mg9h@yahoo.com) 1 Jun 2001 04:07
QH@
Thanx now I got AC and I want to ask you something...
Posted by Ivo 2 Jun 2001 00:18
Kak se kazva tozi algoritam?
Kato gledam imash 104 resheni zadaci
ot koga si w sastezanieto, kolko
cesto ima online sastezaniq?
Blagodarq,
Cao!!!
Re: Thanx now I got AC and I want to ask you something...
Posted by Jivko Ganev 2 Jun 2001 02:53
Did you read that you should post in english ? The text is
little above the submit button. Posting in non-english
languages sux so don't do it.
> Kak se kazva tozi algoritam?
There is no name for this algorithm it is obvious solution.
> Kato gledam imash 104 resheni zadaci
> ot koga si w sastezanieto, kolko
> cesto ima online sastezaniq?
To see how often are the online contests check the schedule
page regulary.
> Blagodarq,
> Cao!!!