hdu 2098 分拆素数和
来源:互联网 发布:莱特币源码 编辑:程序博客网 时间:2024/06/05 13:15
原题链接:http://acm.hdu.edu.cn/showproblem.php?pid=2098
打表,二分。。
#include<algorithm>#include<iostream>#include<cstdlib>#include<cstring>#include<cstdio>#include<vector>#include<map>#include<set>using std::cin;using std::cout;using std::endl;using std::find;using std::sort;using std::set;using std::map;using std::pair;using std::vector;using std::lower_bound;#define sz(c) (int)(c).size()#define all(c) (c).begin(), (c).end()#define iter(c) __typeof((c).begin())#define cls(arr,val) memset(arr,val,sizeof(arr))#define cpresent(c, e) (find(all(c), (e)) != (c).end())#define rep(i, n) for (int i = 0; i < (int)(n); i++)#define tr(c, i) for (iter(c) i = (c).begin(); i != (c).end(); ++i)#define pb(e) push_back(e)#define mp(a, b) make_pair(a, b)const int Max_N = 10010;typedef unsigned long long ull;struct PrimeSpilt { int tot, prime[Max_N]; inline bool isPrime(int n) { for(int i = 2; i * i <= n; i++) { if(!(n % i)) return false; } return n != 1; } inline void init() { tot = 0; for(int i = 1;i < Max_N ;i++) { if(isPrime(i)) prime[tot++] = i; } } inline void work(int n) { int ans = 0; for(int i = 0;i < tot && prime[i] < n; i++) { int p = lower_bound(prime + i, prime + tot, n - prime[i]) - prime; if(prime[i] + prime[p] == n && i != p) ans++; } printf("%d\n", ans); }}go;int main() {#ifdef LOCAL freopen("in.txt","r",stdin); freopen("out.txt","w+",stdout);#endif int n; go.init(); while(~scanf("%d", &n) && n) go.work(n); return 0;}
0 0
- HDU 2098 分拆素数和(素数)
- HDU 2098 分拆素数和
- HDU 2098 分拆素数和
- HDU 2098 - 分拆素数和
- HDU 2098 分拆素数和
- hdu 2098 分拆素数和
- Hdu 2098 分拆素数和
- HDU 2098 分拆素数和
- HDU 2098 分拆素数和
- hdu-2098-分拆素数和。。。
- HDU 2098 分拆素数和
- HDU 2098 分拆素数和
- hdu 2098 分拆素数和
- hdu 2098 分拆素数和 水题
- HDU 2098 分拆素数和
- hdu 2098 分拆素数和
- hdu 2098 分拆素数和
- HDU 2098 分拆素数和
- nfs共享三步, linux共享配置
- 使用隐藏字段来保存状态
- 最简单的基于FFMPEG+SDL的音视频播放器
- 百度地图:[BMMapViewManager getCMapControlWithMapView:]闪退问题如何解决?
- 在树莓派上构建Golang及Redis环境
- hdu 2098 分拆素数和
- POJ 3204 Ikki's Story I - Road Reconstruction 残余网络
- 板卡上的日志缓冲区只可以记录1000条日志,当超过1000条记录时,新增的日志将覆盖旧的记录(是最旧的记录)
- Xcode编译常见问题总结
- 开源邮件系统
- 小甲鱼PE详解之输入表(导入表)详解(PE详解07)
- NSArray和NSMutableArray
- java学习之旅01--如何学习
- JAVA的StringBuffer类