A - Design Tutorial: Learn from Math(哥德巴赫猜想)
Problem description
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.
Examples
Input
12
15
23
1000000
Output
4 8
6 9
8 15
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.
解题思路:每个不小于12的整数可以表示为两个合成数之和,若满足条件有多组,则输出其中的一组,简单判断即可。
AC代码:
#include<bits/stdc++.h>
using namespace std;
bool isprime(int x){
for(int i=;i*i<=x;++i)
if(x%i==)return false;
return true;
}
int main(){
int n;cin>>n;
for(int i=;;i+=)
if(!isprime(n-i)){cout<<i<<' '<<(n-i)<<endl;break;}
return ;
}
A - Design Tutorial: Learn from Math(哥德巴赫猜想)的更多相关文章
- cf472A Design Tutorial: Learn from Math
A. Design Tutorial: Learn from Math time limit per test 1 second memory limit per test 256 megabytes ...
- 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 ...
- codeforce A. Design Tutorial: Learn from Math
题意:将一个数拆成两个合数的和, 输出这两个数!(这道题做的真是TMD水啊)开始的时候不知道composite numbers是啥意思,看了3遍才看懂.... 看懂之后又想用素数筛选法来做,后来决定单 ...
- 【CodeForces 472A】Design Tutorial: Learn from Math
题 题意:给你一个大于等于12的数,要你用两个合数表示出来.//合数指自然数中除了能被1和本身整除外,还能被其他的数整除(不包括0)的数. 分析:我们知道偶数除了2都是合数,给你一个偶数,你减去一个偶 ...
- codeforces水题100道 第七题 Codeforces Round #270 A. Design Tutorial: Learn from Math (math)
题目链接:http://www.codeforces.com/problemset/problem/472/A题意:给你一个数n,将n表示为两个合数(即非素数)的和.C++代码: #include & ...
- 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 ...
- cf472B Design Tutorial: Learn from Life
B. Design Tutorial: Learn from Life time limit per test 1 second memory limit per test 256 megabytes ...
- codeforces B. Design Tutorial: Learn from Life
题意:有一个电梯,每一个人都想乘电梯到达自己想要到达的楼层!从a层到b层的时间是|a-b|, 乘客上下电梯的时间忽略不计!问最少需要多少的时间.... 这是一道神题啊,自己的思路不知不觉的就按 ...
- Design Tutorial: Learn from Life
Codeforces Round #270 B:http://codeforces.com/contest/472/problem/B 题意:n个人在1楼,想要做电梯上楼,只有1个电梯,每次只能运k个 ...
随机推荐
- xadmin站点管理类
9. Xadmin xadmin是Django的第三方扩展,比使用Django的admin站点更强大也更方便. 文档:https://xadmin.readthedocs.io/en/latest/i ...
- php 在不知道字符串有多长的情况下,如何去除前三个字符?
$string='字符串';$subject=substr_replace(string,'',0,3);
- 【数据结构】C语言栈的基本操作
#include<stdio.h> #include<stdlib.h> #include<malloc.h> //定义节点 struct Node { int d ...
- 24.通过ngram分词机制实现index-time搜索推荐
一.ngram和index-time搜索推荐原理 1.什么是ngram 假设有一个单词:quick,在5种长度下的ngram情况如下: ngram length=1,q u i c k ...
- python常用三方库 - openpyxl
目录 python常用三方库 - openpyxl 读取Excel文件 写入Excel文件 python常用三方库 - openpyxl openpyxl是一个第三方库, 可以处理xlsx格式的Exc ...
- Python基础-画菱形
方法一 n = int(input('请输入:')) for i in range(1, n, 2): print(('*'*i).center(n)) for i in reversed(range ...
- map put
public class test { static Map<String, Map<String, Integer>> mapB = new HashMap<Strin ...
- noip模拟赛 PA
分析:很显然这是一道搜索题,可能是由于我的搜索打的太不美观了,这道题又WA又T......如果对每一个询问都做一次bfs是肯定会T的,注意到前70%的数据范围,N的值都相等,我们可以把给定N的所有情况 ...
- hdu 3549 最大流
#include<stdio.h> #include<string.h> #include<queue> #include<iostream> usin ...
- K - Count the string kmp_Next数组应用
It is well known that AekdyCoin is good at string problems as well as number theory problems. When g ...