/* ID:tianlin2 PROG:ariprog LANG:C++ */ #include <iostream> #include <fstream> #define MAX 125020 using namespace std; int total=0; ifstream fin("ariprog.in"); ofstream fout("ariprog.out"); class assd { public: int a; int b; assd() { a=-1; b=-1; } }; void assdbubble(assd a[],int total) { int b=0; while(!b){ b=1; for(int i=0;i!=total-1;++i){ if(a[i].b>a[i+1].b){ assd temp=a[i]; a[i]=a[i+1]; a[i+1]=temp; b=0; } } } } int main() { int ass[MAX]={0}; int n,m; assd store[1000]; fin>>n>>m; int sum; for(int i=0;i<=m;++i){ for(int j=i;j<=m;++j){ sum=i*i+j*j; ass[sum]=-1; } } int temp1=m*m+m*m; int temp2=temp1/(n-1); for(int i=0;i<=temp1;++i){ if(ass[i]){ int count=0; for(int b=1;b<=temp2&&(i+b*(n-1))<=temp1;++b){ int j=i; count=0; /* while(ass[j]&&count<n){ j+=b; ++count; }*/ for(;ass[j]&&count<n;j+=b,++count){} /* if(count>=n){ for(int x=j-count*b;x<=j-n*b&&total!=1000;x+=b){ ++total; ass[x]=b; } } */ if(count==n){ //cout<<j-count*b<<' '<<b<<endl; store[total].a=j-count*b; store[total].b=b; ++total; } } } } if(total==0) fout<<"NONE"<<endl; else{ assdbubble(store,total); for(int i=0;i!=total;++i) fout<<store[i].a<<' '<<store[i].b<<endl; } //system("pause"); return 0; }