輸入包含不超過10000 組數據。每組數據包含6個整數r1, c1, r2, c2, r3, c3 (1<=r1, c1, r2, c2, r3, c3<=8). 三個格子A, B, C保證各不相同。ios
對於每組數據,輸出測試點編號和最少步數。測試
1 1 8 7 5 6 1 1 3 3 2 2
Case 1: 7 Case 2: 3
#include <iostream> #include <cstring> #include <string> #include <vector> #include <queue> #include <cstdio> #include <set> #include <math.h> #include <algorithm> #include <queue> #include <iomanip> #include <ctime> #define INF 0x3f3f3f3f #define MAXN 100005 #define Mod 1000000007 using namespace std; int main() { int x,y,x1,y1,x2,y2,k=1; while(cin>>x>>y>>x1>>y1>>x2>>y2) { cout<<"Case "<<k++<<": "; if(y1-y == x1-x) { if( x2-x == y2-y ) { if( x2-x>0 && x1-x>0 || x2-x<0 && x1-x<0 ) cout<<abs(y1-y)+1<<endl; else cout<<abs(y1-y)<<endl; } else cout<<abs(y1-y)<<endl; } else cout<<max( abs(x1-x) , abs(y1-y) )<<endl; } return 0; }