USACO Section 1.4 Arithmetic Progressions (ariprog)
2013-10-13 07:49
375 查看
暴力。。
加了一个无脑剪枝,水过去了。。
加了一个无脑剪枝,水过去了。。
/* ID:kkkwjx1 LANG: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 Mother's Milk(BFS)
- USACO-Section1.4 Arithmetic Progressions【暴力枚举】
- USACO-Section 1.4 Mother Milk[模拟][搜索]
- USACO Section 1.4 Arithmetic Progressions(枚举)
- USACO-Section1.4 Prime Cryptarithm (搜索)
- USACO-Section 1.4 Arithmetic Progressions
- C++——USACO Section 1.4 题解
- USACO-Section 1.4 Arithmetic Progressions(枚举)
- USACO Section 1.4 - Mother's Milk(DFS + 记忆化)
- USACO Section1.4 Arithmetic Progressions
- USACO Section 1.4 Arithmetic Progressions
- USACO-Section1.4 Mother's Milk [搜索]
- USACO 1.4 ariprog 解题报告
- USACO Section 1.4 More Search Technique
- USACO Section 1.4 Mother's Milk
- USACO 1.4 ariprog
- USACO Section 1.4 Mother's Milk 搜索
- USACO Section 1.4 - Arithmetic Progressions (暴力)
- USACO - Chapter1 Section 1.4 - Arithmetic Progressions
- USACO-Section1.4 Arithmetic Progressions[其他][暴力枚举]