HDU 2098 split Prime and

Source: Internet
Author: User

Problem description to split an even number into two different primes, and how many are there? Input inputs contain positive even numbers that do not exceed 10000, the number does not exceed 500, and if 0 is the end. Output corresponds to each even number, and outputs the numbers that are split into different primes, one for each row. Sample Input30260 Sample Output32 first hit the prime table, another one to judge, water do not know why, compile errors
#include <cstdio>#include<iostream>#include<cmath>using namespacestd;intprime[10000];voidInit_prime () {intI, J;  for(i =2; I <= sqrt (10001.0); ++i) {if(!Prime[i]) for(j = i * I; J <10001; J + =i) prime[j]=1; } J=0;  for(i =2; I <=10001; ++i)if(!Prime[i]) prime[j++] =i;}BOOLFintNinti) {    intt = N-Prime[i];  for(intj = i +1;p Rime[j] < n;j++)        if(t = = Prime[j])return true; return false;}intMain () {intN;    Init_prime ();  while(Cin >>N) {        if(N = =0) Break; intn =0;  for(inti =0;p Rime[i] < N/2; i++){            if(f (n,i)) n++; } cout<< N <<Endl; }    //System ("pause");    return 0;}


Choose the wrong language, embarrassed ....

HDU Choose c + +!!!

HDU 2098 split Prime and

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.