UVa10948 - The primary problem
来源:互联网 发布:京东盈利模式 知乎 编辑:程序博客网 时间:2024/06/05 17:31
#include <cstdio>#include <cstring>#include <cmath>#include <vector>using namespace std;const int N = 1000000 + 10;void init();bool vis[N];vector<int> v;int main(){ int n;#ifndef ONLINE_JUDGE freopen("uva_in.txt", "r", stdin);#endif init(); while (scanf("%d", &n) == 1) { if (n == 0) break; printf("%d:\n", n); if (n & 1) { if (vis[n - 2]) printf("%d+%d\n", 2, n - 2); else printf("NO WAY!\n"); continue; } for (size_t i = 0; i < v.size(); i++) { if (n < v[i]) break; if (vis[n - v[i]]) { printf("%d+%d\n", v[i], n - v[i]); break; } } } return 0;}void init(){ int m = (int)sqrt(N); memset(vis, true, sizeof(vis)); vis[0] = vis[1] = false; for (int i = 2; i <= m; i++) { if (vis[i]) { for (int j = i * i; j < N; j += i) vis[j] = false; } } for (int i = 2; i < N; i++) { if (vis[i]) v.push_back(i); }}
- UVa10948 - The primary problem
- UVa 10948 - The primary problem
- POJ Problem 2562 Primary Arithmetic
- Recovering the Primary's Datafile
- UVa Problem Solution: 10035 - Primary Arithmatic
- JPA Primary Keys through ManyToOne Relationships problem
- (hnust 1208)Problem C: Primary Arithmetic(水题)
- Delete archivelog in the primary database
- them for the primary five fifa ballon
- UVa Problem 10035 Primary Arithmetic (小学生算术)
- LOV for Editable Primary Key in ADF Table Problem
- We can create the index before creating the primary key.
- The primary key can work with the index well
- The Cost of GUIDs as Primary Keys(转贴)
- configure secondary IPs to overlap the primary ip
- Drupal 4.7: Primary Links and the Menu System
- ASPxGridView A primary key field specified via the KeyFieldName..
- Ticket Servers: Distributed Unique Primary Keys on the Cheap
- WPF中的实现类似Excel的动态条件格式
- Struts的回显
- gc日志分析工具
- iframe页面里的js调用父级页面js函数的解决方法
- CMake 使用方法
- UVa10948 - The primary problem
- uploadify(或swfupload)刷新页面时IE下不断报JS Error的bug的处理
- 在Win7上用Tomcat发布网站--工作收获
- 设置Oracle的默认的时间显示格式
- SQLServer存储过程学习
- Controller 使用RestTemplate进行单元测试 spring mvc
- Win7 下 超级终端安装-配置交换机-【SecureCRT 7.0的安装与注册】 win7 administrator 权限
- nginx负载均衡实践及反向代理
- 早该知道的7个JavaScript技巧