题目链接:http://www.codeforces.com/problemset/problem/472/A
题意:给你一个数n,将n表示为两个合数(即非素数)的和。
C++代码:
#include <iostream> using namespace std; bool isprime(int x) { for (int i = 2; i * i <= x; i ++) if (x % i == 0) return false; return true; } int main() { int n; cin >> n; for (int i = 4;i <= n/2; i ++) if (!isprime(i) && !isprime(n-i)) { cout << i << " " << n-i << endl; break; } return 0; }