题目描述是拿来吓人的,废话一筐箩(图表看第一行就行了)。就按标题说的,Do solve it directly!直接按照给出的函数递归实现,其他什么都是浮云。
Run Time: 0.01sec
Run Memory: 304KB
Code length: 582Bytes
SubmitTime: 2011-12-18 00:49:53
// Problem#: 1797
// Submission#: 1089637
// The source code is licensed under Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License
// URI: http://creativecommons.org/licenses/by-nc-sa/3.0/
// All Copyright reserved by Informatic Lab of Sun Yat-sen University
#include <cstdio>
using namespace std;
int x, y;
int face;
void z( int A, int B ) {
if ( A > 0 && B > 0 ) {
switch ( face ) {
case 0: y++; break;
case 1: x++; break;
case 2: y--; break;
case 3: x--; break;
}
z( A - B, B );
face = ( face + 1 ) % 4;
z( B - A, A );
}
}
int main()
{
int C, A, B;
scanf( "%d", &C );
while ( C-- ) {
scanf( "%d%d", &A, &B );
x = 0;
y = 0;
face = 0;
z( A, B );
printf( "%d %d\n", x, y );
}
return 0;
}