codeforces水题100道 第七题 Codeforces Round #270 A. Design Tutorial: Learn from Math (math)

时间:2023-03-09 01:28:47
codeforces水题100道 第七题 Codeforces Round #270 A. Design Tutorial: Learn from Math (math)

题目链接: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++