原题链接: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. 使用Visual Studio建立报表--C#

    原文:使用Visual Studio建立报表--C# 版权声明:本文为博主原创文章,未经博主允许不得转载. https://blog.csdn.net/qq_23893313/article/deta ...

  2. bzoj2733: [HNOI2012]永无乡(splay)

    2733: [HNOI2012]永无乡 Time Limit: 10 Sec  Memory Limit: 128 MBSubmit: 3778  Solved: 2020 Description 永 ...

  3. 新博客 http://kunyashaw.com/

    感谢博客园. 请关注我的新博客: http://kunyashaw.com/

  4. 我对于js注入的理解

    资料:http://blog.csdn.net/gisredevelopment/article/details/41778671 js注入就是在前端利用使用js的地方 在这其中注入你写的js代码 使 ...

  5. copy & deepcopy

    1 import copy 2 3 字典参照列表结论,看是否有深层嵌套. 4 a = {'name':1,'age':2} 5 b = a 6 a['name'] = 'ff' 7 print(a) ...

  6. PostgreSQL查看索引的使用情况

    查看某个表的索引使用情况 select relname, indexrelname, idx_scan, idx_tup_read, idx_tup_fetch from pg_stat_user_i ...

  7. Form 组件动态绑定数据

    1.Form 组件的作用: a.对用户提交的数据进行验证(form表单/ajax) b.保留用户上次输入的信息 c.可以生成html标签(input表单类的标签) 2..由于form组件中每个字段都是 ...

  8. Leetcode 542.01矩阵

    01矩阵 给定一个由 0 和 1 组成的矩阵,找出每个元素到最近的 0 的距离. 两个相邻元素间的距离为 1 . 示例 1: 输入: 0 0 0 0 1 0 0 0 0 输出: 0 0 0 0 1 0 ...

  9. github pages+阿里云域名绑定搭建个人博客

    1.选择mast 配置cname 设置域名 同时在github设置里面进行绑定 2.获取github pages的ip地址 打开你的电脑的命令行工具,ping你的github地址,忽略"/& ...

  10. [oldboy-django][2深入django]django一个请求的生命周期 + WSGI + 中间件

    1 WSGI # WSGI(是一套协议,很多东西比如wsgiref, uwsgiref遵循这一套协议) - django系统本质 别人的socket(wsgiref或者uwsgiref) + djan ...