Ejemplo n.º 1
0
Archivo: 1312.c Proyecto: saki45/OJ
int main(){
	int primeMap[1001], count, *primeList, N, C, idx, st, ed, mid;
	count = getPrimeMap(primeMap);
	primeList = (int*)calloc(count, sizeof(int));
	getPrimeList(primeMap, primeList);
	while(scanf("%d %d", &N, &C) != EOF){
		idx = bSearch(primeList, count, N);
		if((idx+1)%2 == 1){
			mid = idx>>1;
			st = mid-C+1>=0?mid-C+1:0;
			ed = mid+C-1<=idx?mid+C-1:idx;
		}
		else{
Ejemplo n.º 2
0
int main(int argc, char *argv) {
  char primeList[BOUND];
  int i, j, k, l, m;
  int next, tmp;

  getPrimeList(primeList);
  
  for (i = 3; i < BOUND; getNextPrime(primeList,&i)) {
    for (j = i + 1, getNextPrime(primeList, &j); 
	 j < BOUND; getNextPrime(primeList,&j)) {
      if (connect(i, j) == 1) break;
      if (check(i, j, primeList)) {
	for (k = j + 1, getNextPrime(primeList, &k);
	     k < BOUND; getNextPrime(primeList, &k)) {
	  if (connect(j, k) == 1) break;
	  if (check(j, k, primeList) && check(i, k, primeList)) {
	    for (l = k + 1, getNextPrime(primeList, &l);
		 l < BOUND; getNextPrime(primeList, &l)) {
	      if (connect(k, l) == 1)break;
	      if (check(k, l, primeList) && check(j, l, primeList) && check(i, l,primeList)) {
		for (m = l + 1, getNextPrime(primeList, &m); m < BOUND; getNextPrime(primeList, &m)){
		  if (connect(l, m) == 1)break;
		    if (check(l, m, primeList) && check(k, m, primeList) 
			&& check(j, m, primeList) && check(i, m, primeList)) {
		      printf("%d %d %d %d\n",i,j,k,l);
		      return 0;
		    }
		  }
	      }
	    }
	  }
	}
      }
    }
  }  
  return 0;
}