Proof of poj 2262 godebach conjecture and prime number screening

Source: Internet
Author: User

Learn how to filter prime numbers in 1-N. Note that all prime numbers except 2 must be odd.

This question is related to the Golden Bach conjecture.

# Include <iostream> # include <cmath> using namespace STD; int array [1000000] = {0}; int main () {// The difficulty lies in how to filter prime numbers within 1-most efficiently, it is easy to cause timeout or hyperspace. // learn the prime number embedding method from this question. // first, remove all the even numbers greater than 2. // CIN and cout are slower than printf, this will cause refor (INT I = 4; I <1000000; I + = 2) {array [I] = 1;} For (INT I = 3; I <SQRT (1000000 + 0.0); I + = 2) {If (! Array [I]) {int T = I * I; int T = I; array [T] = 1; // remove the number of rows while (T <1000000) {T + = 2; t = I * t; // remove all I + multiples, I + 4x, and so on. array [T] = 1 ;}}} int N; while (scanf ("% d", & N), n) {for (INT I = 3; I <= n/2; I ++) {If (array [I] = 0 & array [n-I] = 0) {printf ("% d = % d + % d/N", n, i, n-I); break ;}}
} Return 0 ;}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.