HDU 2098 split primes and number theory

Source: Internet
Author: User
Tags cas

Split Prime andTime limit:1000MS Memory Limit:32768KB 64bit IO Format:%i64d &%i64 U

Description

To split an even number into two different prime numbers, how many methods are there?

Input

The input contains some positive even numbers, the value will not exceed 10000, the number will not exceed 500, if in the event of 0, the end.

Output

corresponding to each even, the output is split into the number of different primes, each result occupies a row.

Sample Input

30 26 0

Sample Output

3 2 The key is to do a pre-treatment
#include <iostream> #include <cstring> #include <cstdio> #include <algorithm> #include < queue> #include <vector> #include <iomanip> #include <math.h>using namespace std; #define FIN     Freopen ("Input.txt", "R", stdin), #define INF     0x3f3f3f3f#define lson l,m,rt<<1#define rson    m+1,r, Rt<<1|1typedef Long Long Ll;int p[10005];int s[5005];int main () {    //fin    int cas=0;    for (int i=2, i<=10000; i++)    {        if (p[i]==0)        {for            (int j=i+i; j<=10000; j=j+i)            {                p[j]= 1    ;    }}} for (int i=2; i<=10000; i++)    {        if (p[i]==0)            s[cas++]=i;    }    int n;    while (~SCANF ("%d", &n) &&n)    {        int cnt=0;        for (int i=3; i<n/2; i+=2)        {            if (!p[i]&&!p[n-i])                cnt++;        }        printf ("%d\n", CNT);    }}

  

HDU 2098 split primes and number theory

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.