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.

【注意】:埃氏筛法筛素数时,注意开头i*2非i*i(数字大爆int)

【代码】:

#include<bits/stdc++.h>
using namespace std;
int prime[];
void get_prime()
{
prime[]=prime[]=;//0,1非素数
for(int i=;i<=;i++)
{
if(prime[i]==)
for(int j=i*;j<=;j+=i)
prime[j]=;
}
}
int main()
{
int n;
get_prime();
cin>>n;
for(int i=;i<=n;i++)
if( prime[i]&& prime[n-i] )
{
printf("%d %d\n",i,n-i);
return ;
}
return ;
}

筛法

Codeforces Round #270 A. Design Tutorial: Learn from Math【数论/埃氏筛法】的更多相关文章

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

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

  2. Codeforces Round #270 D Design Tutorial: Inverse the Problem --MST + DFS

    题意:给出一个距离矩阵,问是不是一颗正确的带权树. 解法:先按找距离矩阵建一颗最小生成树,因为给出的距离都是最短的点间距离,然后再对每个点跑dfs得出应该的dis[][],再对比dis和原来的mp是否 ...

  3. cf472A Design Tutorial: Learn from Math

    A. Design Tutorial: Learn from Math time limit per test 1 second memory limit per test 256 megabytes ...

  4. 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 ...

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

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

  6. codeforce A. Design Tutorial: Learn from Math

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

  7. Codeforces Round #270 A~D

    Codeforces Round #270 A. Design Tutorial: Learn from Math time limit per test 1 second memory limit ...

  8. Codeforces Round #270 1001

    Codeforces Round #270 1001 A. Design Tutorial: Learn from Math time limit per test 1 second memory l ...

  9. 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 ...

随机推荐

  1. 剑指Offer - 九度1361 - 翻转单词顺序

    剑指Offer - 九度1361 - 翻转单词顺序2013-11-23 02:45 题目描述: JOBDU最近来了一个新员工Fish,每天早晨总是会拿着一本英文杂志,写些句子在本子上.同事Cat对Fi ...

  2. JMeter学习笔记(三) 录制脚本

    jmeter测试脚本,可以通过其他工具进行录制,例如 BadBoy,我之前使用过此工具,安装以及使用都比较简单的,大家可以在网上搜索一下. 在此整理一下jmeter自带的录制功能,进行录制脚本. 1. ...

  3. 常用模块(time)

    import time # data = time.time() # 获取时间戳# data = time.localtime() # 获取操作系统时间,也称本地时间,可传入时间戳# data = t ...

  4. Python全栈工程师 (类变量、方法、继承、覆盖)

    ParisGabriel                每天坚持手写  一天一篇  决定坚持几年 为了梦想为了信仰    开局一张图 Python人工智能从入门到精通 补充: 实例方法都是操作实例对象 ...

  5. bitbucket相关操作

    常见命令: git checkout -b develop master 创建Develop分支的命令 git checkout master 切换到Master分支 git merge --no-f ...

  6. React跨域问题解决

    https://segmentfault.com/q/1010000012732581 非跨域问题报错 -rpccorsdomain="http://localhost:3000" ...

  7. java案例1,打印hello java

    package anli1; public class hellojava { public static void main(String []args){ System.out.println(& ...

  8. nyoj 题目36 最长公共子序列

    最长公共子序列 时间限制:3000 ms  |  内存限制:65535 KB 难度:3   描述 咱们就不拐弯抹角了,如题,需要你做的就是写一个程序,得出最长公共子序列.tip:最长公共子序列也称作最 ...

  9. error MSB6006: “aapt.exe”已退出,代码为-1073741819

    今天升级了Xamarin和Android SDK之后连模板程序生成都报这个错误,真是想剁手啊,最后在google同学的帮助下搜索到了Xamarin官方论坛上的回答 这个问题是生成工具版本选择的问题,似 ...

  10. 泛型与非泛型集合类的区别及使用例程,包括ArrayList,Hashtable,List<T>,Dictionary<Tkey,Tvalue>,SortedList<Tkey,Tvalue>,Queue<T>,Stack<T>等

    泛型与非泛型集合类在C#程序中是非常重要的一个基础概念,这里列一个表来进行对比: 非泛型集合类 泛型集合类 描述 ArrayList List<T> 表示具有动态大小的对象数组 Hasht ...