Sicily 1797. Do solve it directly

题目很长,废话很多。其实题目很简单,按题目说的做就行。直接按照公式递归做。

/* source code of submission 312639, Zhongshan University Online Judge System */ #include<cstdio> using namespace std; int n,a,b; int x,y,d; void go() { switch( d ) { case 0: y+=1; break; case 1: x+=1; break; case 2: y-=1; break; case 3: x-=1; break; } } void solve(int a, int b) { if ( a<=0 || b<=0 ) return; go(); solve(a-b,b); d=(d+1)%4; solve(b-a,a); } int main() { scanf("%d", &n); while ( --n>=0 ) { scanf("%d%d", &a, &b); x=y=0; d=0; solve(a,b); printf("%d %d/n",x, y); } return 0; }

你可能感兴趣的:(System,Go)