题意:给你一个大于等于12的数,要你用两个合数表示出来。//合数指自然数中除了能被1和本身整除外,还能被其他的数整除(不包括0)的数。

分析:我们知道偶数除了2都是合数,给你一个偶数,你减去一个偶数得到的就是偶数啦,因为n>=12,所以减去4的话,得到的是>=8的偶数,肯定也是合数,当然你也可以减去6、8,大于8就不行了。

然后给你奇数呢?你减去一个奇数就得到偶数啦,减去一个是合数的奇数,最小的就是9,奇数时:n>=13,n-9>=4

#include<stdio.h>
int main(){
int a,b;
int n;
scanf("%d",&n);
if(n%){
printf("%d %d\n",,n-);
}else{
printf("%d %d\n",,n-);
}
return ;
}

这题也可以枚举

#include<stdio.h>
int isComposite(int a){
if(a==)return ;
for(int i=;i*i<=a;i++)
if(a%i==)return ;
return ;
} int main(){
int a,n;
scanf("%d",&n);
for(a=;a<n;a++)
if(isComposite(a)&&isComposite(n-a)){
printf("%d %d",a,n-a);
break;
}
return ;
}

【CodeForces 472A】Design Tutorial: Learn from Math的更多相关文章

  1. cf472A Design Tutorial: Learn from Math

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

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

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

  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水题100道 第七题 Codeforces Round #270 A. Design Tutorial: Learn from Math (math)

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

  6. codeforce A. Design Tutorial: Learn from Math

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

  7. 【codeforces 415D】Mashmokh and ACM(普通dp)

    [codeforces 415D]Mashmokh and ACM 题意:美丽数列定义:对于数列中的每一个i都满足:arr[i+1]%arr[i]==0 输入n,k(1<=n,k<=200 ...

  8. cf472B Design Tutorial: Learn from Life

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

  9. 【77.78%】【codeforces 625C】K-special Tables

    time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standa ...

随机推荐

  1. POJ 1703 Find them,Catch them ----种类并查集(经典)

    http://blog.csdn.net/freezhanacmore/article/details/8774033?reload  这篇讲解非常好,我也是受这篇文章的启发才做出来的. 代码: #i ...

  2. POJ 2318 TOYS【叉积+二分】

    今天开始学习计算几何,百度了两篇文章,与君共勉! 计算几何入门题推荐 计算几何基础知识 题意:有一个盒子,被n块木板分成n+1个区域,每个木板从左到右出现,并且不交叉. 有m个玩具(可以看成点)放在这 ...

  3. 我为什么反对推荐新人编程C/C++语言入门?

    虽然我接触编程以及计算机时间比较早,但是正式打算转入程序员这个行当差不多是大学第四年的事情 从03年接触计算机,07年开始接触计算机编程, 期间接触过的技术包括 缓冲区溢出(看高手写的shellcod ...

  4. gridpanel分组汇总

    [ExtJS5学习笔记]第三十节 sencha extjs 5表格gridpanel分组汇总 2015-05-31     86 本文地址:http://blog.csdn.net/sushengmi ...

  5. android 合并两个jar包

    你所要导出的类里边用到了别的jar包.比如说你写的类连接了数据库,用到数据库驱动包oracl.jar(也就是你导入到Myeclipse或eclipse的jdbc包).. .在dos环境下,进入到D盘的 ...

  6. C++的CreateThread实例

    function CreateThread(  lpThreadAttributes: Pointer;           {安全设置}  dwStackSize: DWORD;           ...

  7. Qt——树的搜索

    一.Qt中的树 Qt中树的实现有两种方式.第一种是使用Qt提供的QTreeWidget,很多函数都封装好,比较方便:另一种是通过QTreeView实现,设置它的数据模型,比如使用QStandardIt ...

  8. 简单工厂模式 Simple Factory

    简单工厂模式的作用就是定义一个用于创建对象的接口 在简单工厂模式中,一个工厂类处于对产品类实例化调用的中心位置上,它决定那一个产品类应当被实例化.         先来看看它的组成: 1) 工厂类角色 ...

  9. java实现八皇后问题(递归和循环两种方式)

    循环方式: package EightQueens;   public class EightQueensNotRecursive { private static final boolean AVA ...

  10. [MetaHook] R_SparkStreaks

    By hzqst void R_SparkStreaks(vec_t *pos, int count, int velocityMin, int velocityMax) { int i; parti ...