codeforces-#472A. Design Tutorial: Learn from Math
2014-09-30 10:48
369 查看
题目大意:将一个大于12的数拆成两个合数的,要求和为该数。
解题思路:先将范围内的素数打表,然后直接判断输出即可,详见code。
题目来源:http://codeforces.com/problemset/problem/472/A
code:
解题思路:先将范围内的素数打表,然后直接判断输出即可,详见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; }
相关文章推荐
- codeforces水题100道 第七题 Codeforces Round #270 A. Design Tutorial: Learn from Math (math)
- 【CodeForces 472A】Design Tutorial: Learn from Math
- codeforces 472A Design Tutorial: Learn from Math
- codeforces 472A. Design Tutorial: Learn from Math
- cf472A Design Tutorial: Learn from Math
- Codeforces 472B. Design Tutorial: Learn from Life(坐电梯扯淡题)
- codeforces 之 Design Tutorial: Learn from Life
- codeforces-#472B. Design Tutorial: Learn from Life(贪心)
- Codeforces Design Tutorial: Learn from Math
- [构造 八数码] Codeforces 472E #270 E. Design Tutorial: Learn from a Game
- 【CODEFORCES】 B. Design Tutorial: Learn from Life
- codeforces 472BDesign Tutorial: Learn from Life(简单贪心)
- A. Design Tutorial: Learn from Math
- CF 472A Design Tutorial: Learn from Math
- 472A - Design Tutorial: Learn from Math
- codeforce A. Design Tutorial: Learn from Math
- Codeforces 472B - Design Tutorial: Learn from Life(模拟)
- A. Design Tutorial: Learn from Math
- 472A - Design Tutorial: Learn from Math
- cf472A Design Tutorial: Learn from Math