1、题目链接地址
http://poj.org/problem?id=1657
2、源代码
#include<iostream> using namespace std; int main() { int T; cin >> T; while(T--) { char a[4]; cin >> a[0] >> a[1] >> a[2] >> a[3]; int l1, l2; int s1, s2, s3; l1 = (a[2] > a[0] )? a[2] - a[0] : a[0] - a[2] ; l2 = (a[3] > a[1] )? a[3] - a[1] : a[1] - a[3] ; if( l1 == 0 && l2 == 0) { cout << "0 0 0 0" << endl ; continue; } s1 = (l1 > l2) ? l1 : l2; if(l1 == l2 || (l1 == 0 && l2 != 0)|| (l2 == 0 && l1 != 0)) { s2 = 1; } else { s2 = 2; } if((l1 == 0 && l2 != 0)|| (l1 != 0 && l2 == 0)) { s3 = 1; } else { s3 = 2; } cout << s1 << " " << s2 << " " << s3 << " "; if(l1 == l2) { cout << "1" << endl; } else if(l1 % 2 == l2 % 2 ) { cout << "2" << endl; } else { cout << "Inf" << endl; } } return 0; }
3、总结
这是很久以前写的东西,看到这些东西,我就在想,有时候只需要找到问题的规律就行了。