codeforce A. Design Tutorial: Learn from Math
题意:将一个数拆成两个合数的和, 输出这两个数!(这道题做的真是TMD水啊)开始的时候不知道composite numbers是啥意思,看了3遍才看懂....
看懂之后又想用素数筛选法来做,后来决定单个判断一个数是否为素数的方法来写,结果写错了两次,快疯掉了简直....
#include<iostream>
#include<cmath>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<cstring>
#define N 1000005
using namespace std; bool prime(int x){
int n = (int)sqrt(x*1.0);
int i;
for(i=; i<=n; ++i)
if( x % i == )
break;
if(i>n) return true;
return false;
} int main(){ int n;
cin>>n;
for(int i=; i<=n/; ++i){
if( !prime(i) && !prime(n-i)){
cout<<i<<" "<<n-i<<endl;
break;
}
}
return ;
}
codeforce 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 ...
- 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 ...
- 【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个 ...
随机推荐
- WebClient的异步处理
using System; using System.Collections.Generic; using System.Linq; using System.Net; using System.Te ...
- HBM内存介绍
原帖地址:http://www.anandtech.com/show/9969/jedec-publishes-hbm2-specification The high-bandwidth memory ...
- c# 字体安装
[DllImport("kernel32.dll", SetLastError = true)] static extern int WriteProfileString(stri ...
- Swift入门篇-循环语句
今天早上一起来所有新闻都是报道荷兰5-1战胜西班牙,我一看没有搞错吧,顿时想都如果中国队vs荷兰队也不至于会输的怎么惨吧,难道是荷兰队开挂了,于是我看了一下昨天比赛的视频直播,还真是新闻报道的那样,顿 ...
- Android基本功:手势
一.概念 手势:其实是指用户手指或触摸笔在屏幕上的连续触碰行为,Andoird对两种手势行为都提供了支持: Andorid提供了手势检测,并为手势检测提供了相应的监听器: Android允许开发者添加 ...
- linux下IM server搭建
一步一步开始做. 附录: 一套开源协议:http://www.igniterealtime.org/index.jsp Proso:http://prosody.im/ 那谁网友的笔记http://w ...
- 【Vegas原创】RHEL6.2安装vmtools
1,mount虚拟cdrom # mount /dev/cdrom /mnt/cdrom 2, ls一下,看有没有 # cd /mnt/cdrom # ls –l ...
- Unix Pipes to Javascript Pipes
Unix Pipes Unix管道扫描稿 简单样例: $ netstat -apn | grep 8080 相信这个大家经常使用,这里就不细说了. 那么管道基本思想是什么呢? 让每个程序只完成一件事, ...
- GoldenGate 配置extract,replicat进程自启动
在GoldenGate中主进程是manager进程,使用start mgr启动.可以在mgr进程中添加一些参数用来在启动mgr进程的同时启动extract和replicat进程 GGSCI (gg01 ...
- centos 7 /etc/rc.local 开机不执行的问题
最近发现centos7 的/etc/rc.local不会开机执行,于是认真看了下/etc/rc.local文件内容的就发现了问题的原因了 1 2 3 4 5 6 7 8 9 10 11 #!/bin/ ...