codeforces-#472A. Design Tutorial: Learn from Math
来源:互联网 发布:yy音效软件 编辑:程序博客网 时间:2024/05/18 01:07
题目大意:将一个大于12的数拆成两个合数的,要求和为该数。
解题思路:先将范围内的素数打表,然后直接判断输出即可,详见code。
题目来源:http://codeforces.com/problemset/problem/472/A
code:
#include <iostream>#include <cstdio>#include <cstring>using namespace std;const int MAXN = 1e6;int n,x,y;int pri[MAXN];void init(){ memset(pri,0,sizeof(pri)); for(int i=2;i<=MAXN;++i) for(int j=2;j*i<=MAXN;++j) pri[i*j]=1;}int main(){ init(); while(~scanf("%d",&n)){ for(int i=2;i<n;++i) if(pri[i] && pri[n-i] && n-i<n){ printf("%d %d\n",i,n-i); break; } } return 0;}
0 0
- codeforces 472A. Design Tutorial: Learn from Math
- codeforces-#472A. Design Tutorial: Learn from Math
- codeforces 472A Design Tutorial: Learn from Math
- 472A - Design Tutorial: Learn from Math
- 472A - Design Tutorial: Learn from Math
- Codeforces Design Tutorial: Learn from Math
- A. Design Tutorial: Learn from Math
- A. Design Tutorial: Learn from Math
- CF 472A Design Tutorial: Learn from Math
- Codeforces #270 A. Design Tutorial: Learn from Math(数论:素数判断)
- cf472A Design Tutorial: Learn from Math
- [构造 八数码] Codeforces 472E #270 E. Design Tutorial: Learn from a Game
- Codeforces 472B - Design Tutorial: Learn from Life(模拟)
- codeforces-#472B. Design Tutorial: Learn from Life(贪心)
- codeforces 之 Design Tutorial: Learn from Life
- 【CODEFORCES】 B. Design Tutorial: Learn from Life
- Codeforces Round #270--B. Design Tutorial: Learn from Life
- Codeforces 472B. Design Tutorial: Learn from Life(坐电梯扯淡题)
- 解决Fragment中放置ViewPager,不执行adapter的方法
- 制作Windows Server 2012的VHD
- ssh免密码登陆
- Hbase rowkey设计时遗留的陷阱
- 面向对象数据库(Object Oriented Databases
- codeforces-#472A. Design Tutorial: Learn from Math
- ssh证书
- codeforces-#472B. Design Tutorial: Learn from Life(贪心)
- leetcode Sum Root to Leaf Numbers my Solution
- Html细线表格的实现 打印边框设置
- IOS学习 Cell自定义
- 谷歌开源 Google I/O应用源代码,展示Android最佳实践
- MySQL的binlog数据如何查看
- 应用程序无法正常启动(0xc0150002)