/// Raihan Ruhin /// CSE, Jahangirnagar University. /// Dhaka-Bangladesh. /// id: raihanruhin (topcoder / codeforces / codechef / hackerrank / uva / uvalive / spoj), 3235 (lightoj) /// mail: raihanruhin@ (yahoo / gmail / facebook) /// blog: ruhinraihan.blogspot.com #include<bits/stdc++.h> using namespace std; #define SET(a) memset(a,-1,sizeof(a)) #define CLR(a) memset(a,0,sizeof(a)) #define PI acos(-1.0) #define MOD 1000000007 #define MX 100010 int arr[5005][5005]; void precal(int x, int y, int val) { if(x>=502 && y>=502) return; arr[x][y]=val; //right-up x++, y++, val++; arr[x][y]=val; //right-down x++, y--, val++; arr[x][y]=val; //right-up x++, y++, val++; arr[x][y]=val; //left-up x--, y++, val++; precal(x, y, val); return; } int main() { ios_base::sync_with_stdio(0);cin.tie(0); int tc, kk=1, n, m, x, y; string s; char ch; precal(0, 0, 0); cin>>tc; while(tc--) { cin>>x>>y; if(!x && !y) cout<<0<<"\n"; else if(arr[x][y]) cout<<arr[x][y]<<"\n"; else cout<<"No Number\n"; } return 0; }
Friday, 14 August 2015
UVALive 2052 Number Steps (ZOJ 1414, HDU 1391, POJ 1663, SPOJ NSTEPS, Regionals 2000 >> Asia - Tehran)
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment