Need Help in Prime Checking Problem

Revision en1, by 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!

Tags prime checking, special problem

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en2 English gamegame 2018-12-29 04:20:16 79
en1 English gamegame 2018-12-29 04:10:16 818 Initial revision (published)