原题链接:http://codeforces.com/contest/584/problem/D

题意:

给你一个奇数,让你寻找三个以内素数,使得和为这个奇数。

题解:

这题嘛。。。瞎比搞搞就好,首先寻找一个最大的小于这个数的素数,然后减掉之后,就是一个很小的偶数了,然后由哥德巴赫猜想,这个偶数一定能够分解成两个素数的和,然后再瞎比暴力一下就好。复杂度大概是$O(\sqrt{n}log(n))$。

代码:

#include<iostream>
#include<cstring>
using namespace std; int n; bool check(int x) {
for (int i = ; i * i <= x; i++)
if (x % i == )return false;
return true;
} int main() {
cin >> n;
if (check(n)) {
cout << << endl;
cout << n << endl;
return ;
}
for (int i = n; i >= ; i -= ) {
if (check(i)) {
int j = n - i;
if (check(j)) {
cout << << endl;
cout << i << " " << j << endl;
return ;
}
for (int k = j - ; k >= ; k--) {
if (check(k) && check(j - k)) {
cout << << endl;
cout << i << " " << k << " " << j - k << endl;
return ;
}
}
}
}
return ;
}

Codeforces Round #324 (Div. 2) Dima and Lisa 哥德巴赫猜想的更多相关文章

  1. Codeforces Round #324 (Div. 2)解题报告

    ---恢复内容开始--- Codeforces Round #324 (Div. 2) Problem A 题目大意:给二个数n.t,求一个n位数能够被t整除,存在多组解时输出任意一组,不存在时输出“ ...

  2. Codeforces Round #324 (Div. 2) D. Dima and Lisa 哥德巴赫猜想

    D. Dima and Lisa Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/584/probl ...

  3. Codeforces Round #324 (Div. 2)D. Dima and Lisa 数学(素数)

                                                     D. Dima and Lisa Dima loves representing an odd num ...

  4. Codeforces Round #324 (Div. 2) D

    D. Dima and Lisa time limit per test 1 second memory limit per test 256 megabytes input standard inp ...

  5. Codeforces Round #324 (Div. 2)

    CF的rating设置改了..人太多了,决定开小号打,果然是明智的选择! 水 A - Olesya and Rodion #include <bits/stdc++.h> using na ...

  6. Codeforces Round #324 (Div. 2) (哥德巴赫猜想)

    题目:http://codeforces.com/problemset/problem/584/D 思路: 关于偶数的哥德巴赫猜想:任一大于2的偶数都可写成两个素数之和. 关于奇数的哥德巴赫猜想:任一 ...

  7. Codeforces Round #324 (Div. 2) C (二分)

    题目链接:http://codeforces.com/contest/734/problem/C 题意: 玩一个游戏,一开始升一级需要t秒时间,现在有a, b两种魔法,两种魔法分别有m1, m2种效果 ...

  8. Codeforces Round #324 (Div. 2) E. Anton and Ira 贪心

    E. Anton and Ira Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/584/probl ...

  9. Codeforces Round #324 (Div. 2) C. Marina and Vasya 贪心

    C. Marina and Vasya Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/584/pr ...

随机推荐

  1. mysql查询当天的数据

    mysql查询当天的数据 贴代码: #两个时间都使用to_days()函数 select * from reple where to_days(create_time) = to_days(NOW() ...

  2. leetcode 【 Subsets II 】python 实现

    题目: Given a collection of integers that might contain duplicates, S, return all possible subsets. No ...

  3. IOS开发学习笔记016-Foundation框架

     Foundation 框架的学习 一.Foundation 常用结构体 1.NSRange(location,length)  typedef struct _NSRange { NSUIntege ...

  4. day02_02.能被3整除的个位数为6的数

    第2题 能被3整除的个位数为6的数 难度增加一点点,再接再厉 注意: 把一些限制条件,用PHP编程的语言来执行 题目:输出100以内(不含100)能被3整除且个位数为6的所有整数 <?php f ...

  5. Hadoop架构的初略总结(2)

    Hadoop架构的初略总结(2) 回顾一下前文,我们总结了以下几个方面.我们为什么需要Hadoop:Hadoop2.0生态系统的构成:Hadoop1.0中HDFS和MapReduce的结构模型. 我们 ...

  6. 集训队日常训练20181110 DIV2 题解及AC代码

    4375: 孪生素数  Time Limit(Common/Java):1000MS/3000MS     Memory Limit:65536KByteTotal Submit: 324       ...

  7. SQL语句操作符优化

    转载地址:http://database.51cto.com/art/200903/112810.htm IN 操作符 用IN写出来的SQL的优点是比较容易写及清晰易懂,这比较适合现代软件开发的风格. ...

  8. Mysql架构之主从复制

    author:JevonWei 版权声明:原创作品 主从复制架构 架构角色 mysql-master:192.168.198.139 mysql-slave:192.168.198.128 主数据库和 ...

  9. 用jquery实现平滑的页面滚动效果

    通过几句jquery代码实现页面平滑滚动到某一锚点的效果.实现代码来源于https://css-tricks.com/snippets/jquery/smooth-scrolling 实现的jquer ...

  10. 洛谷P3803 【模板】多项式乘法(FFT) 【fft】

    题目 这是一道FFT模板题 输入格式 给定一个n次多项式F(x),和一个m次多项式G(x). 请求出F(x)和G(x)的卷积. 输出格式 第一行2个正整数n,m. 接下来一行n+1个数字,从低到高表示 ...