USACO Section 1.4 Arithmetic Progressions (ariprog)
来源:互联网 发布:淘宝举报卖家怎么举报 编辑:程序博客网 时间:2024/05/17 02:04
暴力。。
加了一个无脑剪枝,水过去了。。
/*ID:kkkwjx1LANG:C++TASK:ariprog*/#include <iostream>#include <cstdio>#include <cstring>#include <queue>#include <algorithm>using namespace std;int main(){ freopen("ariprog.in","r",stdin); freopen("ariprog.out","w",stdout); int N,M; scanf("%d%d",&N,&M); bool bisq[255*255*2]= {false}; for(int i=0; i<=M; ++i) for(int j=i; j<=M; ++j) bisq[i*i+j*j]=true; int note[255*255*2],n=0; for(int i=0; i<=2*M*M; ++i) if(bisq[i]) note[n++]=i; bool ok=false; for(int i=1; i<=2*M*M; ++i) { if((N-1)*i>2*M*M) break; for(int j=0; j<n; ++j) { bool yes=true; for(int k=0; k<N; ++k) { int val=note[j]+k*i; if(!bisq[val]) { yes=false; break; } } if(yes) { printf("%d %d\n",note[j],i); ok=true; } } } if(!ok) puts("NONE"); return 0;}
- USACO Section 1.4 Arithmetic Progressions (ariprog)
- USACO 1.4 Arithmetic Progressions (ariprog)
- USACO Section 1.4 Arithmetic Progressions
- USACO-Section 1.4 Arithmetic Progressions
- USACO Section 1.4 Arithmetic Progressions
- USACO section 1.4.3 Arithmetic Progressions
- USACO Section 1.4 - Arithmetic Progressions (暴力)
- USACO-Section 1.4 Arithmetic Progressions(枚举)
- Section 1.4 Arithmetic Progressions
- USACO 1.4-Arithmetic Progressions
- [usaco]1.4 Arithmetic Progressions
- usaco 1.4 Arithmetic Progressions
- USACO 1.4 Arithmetic Progressions
- USACO 1.4 Arithmetic Progressions
- USACO 1.4-Arithmetic Progressions
- USACO 1.4 Arithmetic Progressions
- USCAO-Section 1.4 Arithmetic Progressions
- USACO1.4.1 Arithmetic Progressions (ariprog)
- linux下添加环境变量的方法
- 本地索引
- 全局索引
- 最佳字段顺序
- java中异常总结-值得一看
- USACO Section 1.4 Arithmetic Progressions (ariprog)
- 支付宝面试算法题
- Android4.0以后屏蔽以及HOME按键事件拦截
- Static NAT with iptables on Linux
- 为一张PCI卡打通经络的过程
- 派生类构造函数执行顺序及虚基类的概念
- Linux系统NAT实现机制的升级改进
- 软考-架构师-知识总结 :一、操作系统
- javascript动态的改变IFrame的高度实现自动伸展