A. Design Tutorial: Learn from Math
time limit per test

1 second

memory limit per test

256 megabytes

input

standard input

output

standard output

One way to create a task is to learn from math. You can generate some random math statement or modify some theorems to get something new and build a new task from that.

For example, there is a statement called the "Goldbach's conjecture". It says: "each even number no less than four can be expressed as the sum of two primes". Let's modify it. How about a statement like that: "each integer no less than 12 can be expressed as the sum of two composite numbers." Not like the Goldbach's conjecture, I can prove this theorem.

You are given an integer n no less than 12, express it as a sum of two composite numbers.

Input

The only line contains an integer n (12 ≤ n ≤ 106).

Output

Output two composite integers x and y (1 < x, y < n) such that x + y = n. If there are multiple solutions, you can output any of them.

Sample test(s)
input
12
output
4 8
input
15
output
6 9
input
23
output
8 15
input
1000000
output
500000 500000
Note

In the first example, 12 = 4 + 8 and both 4, 8 are composite numbers. You can output "6 6" or "8 4" as well.

In the second example, 15 = 6 + 9. Note that you can't output "1 14" because 1 is not a composite number.

给定n,要求找出a,b,使得a、b是合数,并且n=a+b

3分钟打完……感觉手速还是慢

#include<cstdio>
#include<iostream>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<cmath>
#include<queue>
#include<deque>
#include<set>
#include<map>
#include<ctime>
#define LL long long
#define inf 0x7ffffff
#define pa pair<int,int>
using namespace std;
inline LL read()
{
LL x=0,f=1;char ch=getchar();
while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
return x*f;
}
LL n;
LL a[100010];
bool mark[1000010];
int main()
{
n=read();
memset(mark,1,sizeof(mark));
mark[1]=0;
for (int i=2;i<=n;i++)
if (mark[i])
for (int j=2*i;j<=n;j+=i)
mark[j]=0;
for (int i=2;i<=n;i++)
if (!mark[i]&&!mark[n-i]&&i<n-i)
{
printf("%d %d\n",i,n-i);
return 0;
}
}

  

cf472A Design Tutorial: Learn from Math的更多相关文章

  1. Codeforces Round #270 A. Design Tutorial: Learn from Math【数论/埃氏筛法】

    time limit per test 1 second memory limit per test 256 megabytes input standard input output standar ...

  2. A - Design Tutorial: Learn from Math(哥德巴赫猜想)

    Problem description One way to create a task is to learn from math. You can generate some random mat ...

  3. codeforce A. Design Tutorial: Learn from Math

    题意:将一个数拆成两个合数的和, 输出这两个数!(这道题做的真是TMD水啊)开始的时候不知道composite numbers是啥意思,看了3遍才看懂.... 看懂之后又想用素数筛选法来做,后来决定单 ...

  4. 【CodeForces 472A】Design Tutorial: Learn from Math

    题 题意:给你一个大于等于12的数,要你用两个合数表示出来.//合数指自然数中除了能被1和本身整除外,还能被其他的数整除(不包括0)的数. 分析:我们知道偶数除了2都是合数,给你一个偶数,你减去一个偶 ...

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

    题目链接:http://www.codeforces.com/problemset/problem/472/A题意:给你一个数n,将n表示为两个合数(即非素数)的和.C++代码: #include & ...

  6. cf472B Design Tutorial: Learn from Life

    B. Design Tutorial: Learn from Life time limit per test 1 second memory limit per test 256 megabytes ...

  7. Codeforces Round #270--B. Design Tutorial: Learn from Life

    Design Tutorial: Learn from Life time limit per test 1 second memory limit per test 256 megabytes in ...

  8. codeforces B. Design Tutorial: Learn from Life

    题意:有一个电梯,每一个人都想乘电梯到达自己想要到达的楼层!从a层到b层的时间是|a-b|, 乘客上下电梯的时间忽略不计!问最少需要多少的时间....     这是一道神题啊,自己的思路不知不觉的就按 ...

  9. Design Tutorial: Learn from Life

    Codeforces Round #270 B:http://codeforces.com/contest/472/problem/B 题意:n个人在1楼,想要做电梯上楼,只有1个电梯,每次只能运k个 ...

随机推荐

  1. 简单实用后台任务执行框架(Struts2+Spring+AJAX前端web界面可以获取进度)

    使用场景: 在平常web开发过程中,有时操作员要做一个后台会运行很长时间的任务(如上传一个大文件到后台处理),而此时前台页面仍需要给用户及时的进度信息反馈,同时还要避免前台页面超时. 框架介绍: 本架 ...

  2. mybatis源代码分析:深入了解mybatis延迟加载机制

    下文从mybatis(3.2.7)延迟加载样例讲起,逐步深入其实现机制. 下面的例子是Student类关联一个Teacher对象,在访问Student对象时,不立即加载其关联的Teacher对象,而是 ...

  3. c++ 10

    一.二叉树 1.基本特征 1)树型结构的最简模型,每个节点最多有两个子节点--左子节点和右子节点. 2)单根性,每个子节点有且仅有一个父节点,整棵树有且仅有一个根节点. 3)递归性,以任何一个节点为根 ...

  4. 《Java程序员面试笔试宝典》之Java程序初始化的顺序是怎样的

    在Java语言中,当实例化对象时,对象所在类的所有成员变量首先要进行初始化,只有当所有类成员完成初始化后,才会调用对象所在类的构造函数创建对象. Java程序的初始化一般遵循以下三个原则(以下三原则优 ...

  5. 45 个非常有用的 Oracle 查询语句(转)

    这里我们介绍的是 40+ 个非常有用的 Oracle 查询语句,主要涵盖了日期操作,获取服务器信息,获取执行状态,计算数据库大小等等方面的查询.这些是所有 Oracle 开发者都必备的技能,所以快快收 ...

  6. [Hapi.js] Using the response object

    When you use reply method: let resp = reply('hello world') It actually return an response object. By ...

  7. LabView培训

    labview基础到高级官方超全完整视频教程包括数据采集,其他模块的部 分教程,废话不多说. 免费下载地址在结尾. LabVIEW 本事编程(低级)培训LabVIEW作为前辈的图形化编程言语斥地环境, ...

  8. Juqery 中使用 ajax

    从 test.js 载入 JSON 数据,附加参数,显示 JSON 数据中一个 name 字段数据. jQuery 代码: $.getJSON("test.js", { name: ...

  9. 继承之后的使用注意事项_ArrayStoreException

    今天在看Core In Java第五章节时,看到一个很感兴趣的知识点,如下: 在Java中,子类数组的引用可以转换成超类数组的引用,而不需要采用强制转换.但是,在超类数组的引用添加超类类型引用对象之后 ...

  10. 使用Fiddler捕获Java程序中的HTTP请求

      默认Java程序是不支持Fiddler获取请求的,因此需要通过设置代理来实现.   Fiddler的端口是8888,若Fiddler没有运行,则会抛出异常.   HttpClient4.5示例: ...