Arithmetic Progressions
2017.06.04
###题解###
设置所有可能的最高和最低高度,进行计算后取最小值即可。
###代码###
/*
ID: xhzdcyy1
PROB: ariprog
LANG: C++
*/
#include <iostream>
#include <fstream>
#include <string>
#include <algorithm>
#define cin fin
#define cout fout
using namespace std;
ofstream fout ("ariprog.out");
ifstream fin ("ariprog.in");
bool a[200000];
int main()
{
int m,n;
cin>>n>>m;
int max=m*m*2;
for(int i=0;i<=m;i++){
for(int j=0;j<=m;j++){
a[i*i+j*j]=true;
}
}
bool flag=true;
for(int j=1;j<=max/(n-1);j++){
for(int i=0;i<=(max-(n-1)*j);i++){
int k;
for(k=0;k<n;k++){
if(!a[i+k*j]) break;
}
if(k==n){
cout<<i<<" "<<j<<endl;
flag=false;
}
}
}
if(flag) cout<<"NONE"<<endl;
return 0;
}