Need Help in Prime Checking Problem

Правка en1, от gamegame, 2018-12-29 04:10:16

Problem source (Traditional Chinese): https://tioj.ck.tp.edu.tw/problems/2073

Basically, the problem asks to write a program to check whether the T<=5000 numbers (<=1e9) are prime. Moreover, your program must be in C++ and fits the following format:

#include <cstdio>

bool IsPrime(int n) {
  int r=1___f_____r__f___f____n___=0__%__f);
  return_____4_n__;
}

int main() {
  int x;
  while (~scanf("%d", &x)) printf("%d\n", (int)IsPrime(x));
}

I have tried to solve this problem for a long time and couldn't solve it. I have created a "solution", but it only works without -O2 optimization. Link: https://pastebin.com/K9sCXXn2

I desperately wanted to know the solution to this problem. Can somebody drop hints or solutions to this problem? Thanks!

Теги prime checking, special problem

История

 
 
 
 
Правки
 
 
  Rev. Язык Кто Когда Δ Комментарий
en2 Английский gamegame 2018-12-29 04:20:16 79
en1 Английский gamegame 2018-12-29 04:10:16 818 Initial revision (published)