poj 2262

小水题一道。

//============================================================================
// Name        : 2262.cpp
// Author      : 
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;


bool flag[1000010];
int n;

int main() {
	freopen("a.txt", "r", stdin);
	flag[1] = true;
	for(int i = 2;i <= 1000000/2;i++){
		if(flag[i] == false){
			for(int j = i*2;j <= 1000000;j+=i){
				flag[j] = true;
			}
		}
	}
	flag[2] = true;
	while(scanf("%d", &n)&&n){
		for(int i = 3;i <= n;i+=2){
			if(flag[i] == false&&flag[n-i] == false){
				printf("%d = %d + %d\n", n, i, n-i);
				break;
			}
		}
	}
	return 0;
}

  

posted @ 2011-07-24 20:40  KOKO's  阅读(251)  评论(0编辑  收藏  举报