![codeforces水题100道 第七题 Codeforces Round #270 A. Design Tutorial: Learn from Math (math) codeforces水题100道 第七题 Codeforces Round #270 A. Design Tutorial: Learn from Math (math)](https://image.shishitao.com:8440/aHR0cHM6Ly9ia3FzaW1nLmlrYWZhbi5jb20vdXBsb2FkL2NoYXRncHQtcy5wbmc%2FIQ%3D%3D.png?!?w=700&webp=1)
题目链接:http://www.codeforces.com/problemset/problem/472/A
题意:给你一个数n,将n表示为两个合数(即非素数)的和。
C++代码:
#include <iostream>
using namespace std;
bool isprime(int x)
{
for (int i = ; i * i <= x; i ++)
if (x % i == )
return false;
return true;
}
int main()
{
int n;
cin >> n;
for (int i = ;i <= n/; i ++)
if (!isprime(i) && !isprime(n-i)) {
cout << i << " " << n-i << endl;
break;
}
return ;
}
C++