题意:给你一个大于等于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. Android开发环境搭建(转)

    转载:http://www.cnblogs.com/zoupeiyang/p/4034517.html#1 引言   在windows安装Android的开发环境不简单也说不上算复杂,本文写给第一次想 ...

  2. n个整数中,找出尽可能多的数使他们组成一个等差数列,求最长等差数列的长度

    例子:  3,8,4,5,6,2          返回值应该为 :5 这是昨天做的一道优酷土豆的编程题,和leetcode中的128/ Longest Consecutive Sequence 有点 ...

  3. Spring 一二事(3) - 别名

    别名就是可以通过另外一个名字来访问如下,已有bean:helloWorld3,那么定义别名(alias )后,就能使用“abc”来访问 <bean id="helloWorld3&qu ...

  4. 数据结构Java实现06----中缀表达式转换为后缀表达式

    本文主要内容: 表达式的三种形式 中缀表达式与后缀表达式转换算法 一.表达式的三种形式: 中缀表达式:运算符放在两个运算对象中间,如:(2+1)*3.我们从小做数学题时,一直使用的就是中缀表达式. 后 ...

  5. 台北Unity开发者研讨会 笔记

    本文转自:http://ndark.wordpress.com/2013/05/12/20130511-台北unity开发者研讨会-笔记/ (墙外) 说明 本文单纯只是笔记,若有笔误敬请见谅. 相关参 ...

  6. MonoDevelop line endings

    文件编码问题 这个让我头疼很久的问题,每次修改文件后,都会出现这个提示框. 解决办法 之前修改 D:\Program Files (x86)\Unity\Editor\Data\Resources\S ...

  7. centos下安装xampp,Zend Guard,memcached

    这里说的生产环境是php5.4x,要高版本的其实也一样 第一步:安装xampp xampp它是跨平台的,且自带很多拓展,安装之后会为我们省去很多事,使用起来很方便. i>http://sourc ...

  8. mysql学习书籍推荐

    1.<MySQL技术内幕:SQL编程>2.<高性能MySQL>3.<MySQL技术内幕>4. mysql技术内幕.innodb存储引擎

  9. apply,call,bind的区别

    apply.call 在 javascript 中,call 和 apply 都是为了改变某个函数运行时的上下文(context)而存在的,换句话说,就是为了改变函数体内部 this 的指向. Jav ...

  10. Java中的Random()函数

    今天在做Java练习的时候注意到了Java里面的一个随机函数——Random,刚开始只是知道这个函数具有随机取值的作用,于是上网搜索了资料一番,做了一下一些关于Random函数的总结:   Java中 ...