Revision: 48381
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at June 30, 2011 03:02 by Nursoltan
Initial Code
/*
NAME : Nursoltan
PROB : ariprog
LANG : C++
DATE : 30/06/11 01:01
*/
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <sstream>
#include <iostream>
#include <map>
#include <set>
#include <stack>
#include <utility>
#include <queue>
using namespace std;
#define MAX 100
#define INF INT_MAX
#define eps (1e-9)
#define FOR(_i,_k,_n) for(int (_i)=(_k); (_i)<(_n); (_i)++)
#define FORR(_i,_k,_n) for(int (_i)=(_k); (_i)>=(_n); (_i)--)
#define CLR(_x) memset((_x),0,sizeof(_x))
#define SQR(_x) ((_x)*(_x))
#define all(_x) _x.begin(),_x.end()
#define sz(_x) sizeof(_x)
#define vc vector<int>
#define pb push_back
#define mp make_pair
#define iss istringstream
#define oss ostringstream
#define px first
#define py second
typedef long long ll;
typedef pair <int,int> point;
int ABS(int _x){ return _x>0?_x:-_x; }
int main()
{
freopen("ariprog.in","r",stdin);
freopen("ariprog.out","w",stdout);
int N,M;
bool Map[125001]={0};
int a[31640],lna=0;
point ret[1000001];
int lnret=0;
cin>>N>>M;
FOR(p,0,M+1) FOR(q,p,M+1) a[lna++]=p*p+q*q,Map[p*p+q*q]=true;
sort(a,a+lna);
FOR(i,0,lna) FOR(d,1,3000){
bool ok=1;
int a1=a[i];
if(a1>=100000) break;
FOR(k,0,N){ if(!ok || a1+d*k>125001) break; if(Map[a1+d*k]==false) ok=0; }
if(ok && d>0) ret[lnret++]=(mp(d,a1));
}
sort(ret,ret+lnret);
if(lnret==0){ cout<<"NONE\n"; goto GOTOHELL; }
cout<<ret[0].py<<" "<<ret[0].px<<endl;
FOR(i,1,lnret){
if(ret[i].px==ret[i-1].px && ret[i].py==ret[i-1].py) continue;
cout<<ret[i].py<<" "<<ret[i].px<<endl;
}
GOTOHELL :
//system("pause");
return 0;
}
Initial URL
Initial Description
Initial Title
ch1 : Arithmetic Progressions
Initial Tags
Initial Language
C++