cf472A Design Tutorial: Learn from Math
1 second
256 megabytes
standard input
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.
The only line contains an integer n (12 ≤ n ≤ 106).
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.
12
4 8
15
6 9
23
8 15
1000000
500000 500000
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的更多相关文章
- 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 ...
- 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 ...
- 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 & ...
- 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 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 ...
- 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个 ...
随机推荐
- 通过java类文件识别JDK编译版本
类文件中第5,6,7,8四个字节是jDK版本号信息,其中5,6为小版本号:7,8为大版本号. 大版本号对应JDK版本如下: JDK版本号 7,8字节 JDK8 52(0x34) JDK7 51(0x3 ...
- 【Python脚本】Eclipse IDE扩展PyDev插件安装
作为一名Python的初学者,其实不用太在意IDE了,我觉得开始的时候用用自带的 IDLE 也挺好的. 还有 DreamPie 也挺好的.都是一些轻量级的IDE. 因为我正好安装有Eclipse,平时 ...
- batch 批处理获取系统时间
文件test.bat,内容命令如下: @echo off set filename=%,%-%,%-%,% %,%:%,%:%,% echo %filename% pause
- poj 1759 Garland (二分搜索之其他)
Description The New Year garland consists of N lamps attached to a common wire that hangs down on th ...
- pyqt QTimer,QThread例子学习
# -*- coding: utf-8 -*- # python:2.x __author__ = 'Administrator' from PyQt4.QtGui import * from PyQ ...
- springmvc工作原理和环境搭建
SpringMVC工作原理 上面的是springMVC的工作原理图: 1.客户端发出一个http请求给web服务器,web服务器对http请求进行解析,如果匹配DispatcherServle ...
- Unity之Bmob云存储一
无论我们做软件还是做游戏,少不了的就是和数据打交道,对于要保存到本地的数据,我们可以采用的载体太多了.例如:txt,Xml,Sqlite,SqlServer,Mysql等等,具体使用什么那就视情况而定 ...
- jsp页面获取服务器时间
Calendar c = Calendar.getInstance(); int year = c.get(Calendar.YEAR); int month = c.get(Calendar.MON ...
- Could not load file or assembly 'Oracle.DataAccess' or one of its dependencies. An attempt was made to load a program with an incorrect format.
I have installed a Web application on IIS 7.0 windows server 2008 R2 64 bit OS I am refering a oracl ...
- 13年山东省赛 Boring Counting(离线树状数组or主席树+二分or划分树+二分)
转载请注明出处: http://www.cnblogs.com/fraud/ ——by fraud 2224: Boring Counting Time Limit: 3 Sec ...