Page 3 of 7
Posted: Wed May 07, 2003 2:11 pm
by ..
I think it is not a good attitude to ask for extending the time limit.
As you say, there are more than 60 people got accepted within 10s. That means there is some methods to do it in reasonable time.
I think most of us come to this online judge because we want to learn by solving problems. If you don't get fast enough, just think about how to do it faster
P.S. I got it accepted with 8s
Posted: Wed May 07, 2003 2:31 pm
by Dominik Michniewski
From other side:
why problemsetter set time-limit to 40 sec ? I think, that she/he thought that it is reasonable time for solving this problem. So I think, that if problemsetter doesn't set TIME-LIMIT, we should use 10 sec limit. But If PROBLEMSETTER SET LIMIT, we should use your limit .... (and then time-limit could be i.e. 2 sec for other problems ... ). It's my private opinion and I think that when I solve problem in 1/3 of time limit it's good time. I know, that every problem we can solve in very small amount of time, but in many cases it unnecessary ... (this is only my opinion! ) ...
DM
PS. I got Acc in 14 sec
Posted: Wed May 07, 2003 2:51 pm
by Farid Ahmadov
If there are 60 who solved this problem in less than 10 seconds then it means it is possible to solve it:). If you are a good programmer then you will try to do it. Every problem that I have met in online contests the TL for easy problems is 10 seconds or more and memory is 16MB or more. It means that a good programmer will solve it in less time and with less memory. The others will use much more memory or full search algorithm and solve it in more than 10 seconds. If you think that you program is correct then try to optimize it with maximum possible ways.
Good luck.
Posted: Thu Jan 29, 2004 1:21 pm
by yiuyuho
I have a question about the problem specification:
For each line of input produce one line of output. This line should be of one of the following types:
n is not the sum of two primes!
n is the sum of p1 and p2.
For the second case, always make sure that (p2-p1) is positive and minimized.
how can we from there or other parts of the problem to deduce that for 4, or 6 we should output that they are not the sum of 2 primes?
we cannot do 4= 2+2 because 2-2 is not positive, but 4 is not the sum of two primes is also incorrect....and where does it say if it is not case 2 then output case 1?
Thanks
10311 Why do i get OutOfMemoryError
Posted: Sat Oct 30, 2004 10:12 am
by JonyBravo
Can enyone help me
Why my code gets on high numbers OutOfMemoryError
for example on max N=100000000
100000000
Exception in thread "main" java.lang.OutOfMemoryError
My Code:
import java.io.*;
import java.util.*;
public class GoldbachAndEuler2{
final static long maxI=Integer.parseInt("100000000");
static long stevilo;
public static void main(String[] args){
BufferedReader vhod = new BufferedReader(new InputStreamReader(System.in));
while(true) {
try{
String nn = vhod.readLine().trim();
if (nn.equals("")) break;
int mm = Integer.parseInt(nn);
if(mm - stevilo > 0){
stevilo=mm;
if ((0 < mm) && (mm <= maxI)) {
problemL(mm);
}
else {
System.out.println("Stevilo "+ mm +" ni iz intervala [1, "+maxI+"].");
}
}
else{
System.out.println(stevilo +" - "+mm+" < 0 zato koncamo!" );
break;
}
}
catch(Exception ex){
}
}
}
public static void problemL(int stevilo)
{
boolean[] jePrastevilo = new boolean[stevilo];
for(int i = 2; i < stevilo; i++){jePrastevilo = true;}
for(int i = 2; i * i < stevilo; i++){
if(jePrastevilo){
for(int j = i; i * j < stevilo; j++){jePrastevilo[i*j] = false;}
}
}
int prastevilo = 0;
for (int i = 2; i < stevilo; i++){
if (jePrastevilo) prastevilo++;
}
int seznam[] = new int[prastevilo];
int k = 0;//pomik po seznamu
for(int i = 0; i < stevilo; i++){
if(jePrastevilo){seznam[k++] = i;}
}
int levo = 0, desno = prastevilo-1;
boolean nasliSum=false;
while(levo <= desno) {
if(seznam[levo] + seznam[desno] == stevilo){nasliSum=true; break;}
else if(seznam[levo] + seznam[desno] < stevilo){levo++;}
else{desno--;}
}
if (nasliSum){
System.out.println(stevilo + " is the sum of " + seznam[levo] + " and " + seznam[desno]);
}
else{
System.out.println(stevilo + " is not the sum of two primes!");
}
}
}//class
Posted: Sat Oct 30, 2004 8:59 pm
by JonyBravo
10311 Goldbach and Euler.... Compile Error
Posted: Mon Jan 03, 2005 12:25 am
by Antonio Ocampo
Hi, I don't know why I got Compile Error. Please help me!!!
Thanks in advance
Re: 10311 Goldbach and Euler.... Compile Error
Posted: Mon Jan 03, 2005 12:54 am
by stubbscroll
Antonio Ocampo wrote:Hi, I don't know why I got Compile Error. Please help me!!!
Thanks in advance
I get the following compile error:
'main' must return 'int'
Simply replace 'void main' with 'int main'. Also reduce your #define max, or you'll get memory limit exceeded.
Posted: Mon Jan 03, 2005 3:12 am
by Antonio Ocampo
Well, I put void main() in all my AC programs therefore that isn't the problem.
Posted: Mon Jan 03, 2005 8:26 am
by sumankar
The judge should have sent you a mail identifying the lines it can't compile.
I just hope it wasnt as silly a mistake as clicking on C instead of C++ if you are using the web based submission tool
Regards,
Suman.
PS: a quick glance on VC.6 shows link errors, it might be due to the fact that you are using both iostream & cstdio, can you explain why you need both of them?
On a mac g++ cribs on void main, and on correcting that, the bool array seems to be too large, again cribs ... reduced it by a factor of 10 and then it compiles happily even with both the headers.So you have your hands full!
Posted: Fri Jan 21, 2005 5:26 am
by Antonio Ocampo
I sent my code by e-mail and I have received this reply:
Code: Select all
Here are the compiler error messages:
03230701_24.c:39: unterminated string or character constant
03230701_24.c:39: possible real start of unterminated constant
Could someone tell me what does this mean?

hmm
Posted: Fri Jan 21, 2005 11:54 am
by shahriar_manzoor
You must have compiled your code before sending. The possible cause can be that the email sender program has imposed a line break in your program which has caused a compile error;
For example:
printf("jhjadhajhajahdjadhajdhadjahjahajdhajhajshajhajhajhajhajshaj\n");
will compile but
printf("jhjadhajhajahdjadhajdhadjahjahajdha
jhajshajhajhajhajhajshaj\n");
won't compile
Posted: Sat Jan 22, 2005 6:44 am
by Antonio Ocampo
Thx for your reply Shahriar. I got the same answer when I submit my program by "Submit-o-matic 6.0".
This is my code, please help me!!!
Thx in advance

hmm
Posted: Sat Jan 22, 2005 7:59 am
by shahriar_manzoor
The array you hav declared is too big for the judge. You will have to implement the seive using bit. Often we have the misconception that a boolean variable will always occupy 1 bit of memory space as it has two possible values. But the judge should have replied memory limit exceeded but instead it replied compile error.
Posted: Sat Jan 22, 2005 8:08 am
by Antonio Ocampo
Well, I have replaced
Code: Select all
bool no_primo[max+1]={true,true,false};
by
but it doesn't work, any suggestion??