two positions of a NxN chess board can be connected by pawns move(diagonally) iff both of them are on black/white position, this can be checked by checking the pair. if both of the x,y (start position ) and X,Y(end position) are odd,odd or even,even then they can be connected or both of the pair are
Category: Spiral Shape Problem
903
#include <iostream> using namespace std; int main() { int n; int Break=0; long long int res,res1,res2,res3,res4,rank,diff; long long int b_left,b_ryt,t_left,t_ryt; while(cin>>n) { res=1; res1=1; res2=1; res3=1; res4=1; Break=0; if(n==1) { cout<<7<<";"<<8<<";"<<9<<";\n"; cout<<6<<";"<<1<<";"<<2<<";\n"; cout<<5<<";"<<4<<";"<<3<<";\n"; continue; } for(long long int i=0;i<1500000000;i++) { if(Break) break; res1+=i*2; if(res1>=n) { rank=i; res=res1; Break=1; //continue; } res2+=i*4; if(res2>=n) { rank=i; res=res2;