我是靠谱客的博主 合适天空,这篇文章主要介绍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 = 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;
}
C++

 

转载于:https://www.cnblogs.com/moonlightpoet/p/5688858.html

最后

以上就是合适天空最近收集整理的关于codeforces水题100道 第七题 Codeforces Round #270 A. Design Tutorial: Learn from Math (math)的全部内容,更多相关codeforces水题100道内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(156)

评论列表共有 0 条评论

立即
投稿
返回
顶部