Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
贴代码,求优化In Reply To:WA了的,测下这组数据 Posted by:speedcell4 at 2011-03-26 11:12:50 #include<iostream> using namespace std; int t; char a,b,c,d; int ab(int a,int b) { if(a>b) return a-b; else return b-a; } int better(int a,int b) { if(a>b) return a; else return b; } int main() { cin>>t; while(t--) { cin>>a>>b>>c>>d; cout<<better(abs(c-a),abs(d-b))<<" "; if(abs(c-a)==abs(d-b)) { if(a==c) cout<<"0 "; else cout<<"1 "; } else cout<<(a!=c)+(b!=d)<<" "; cout<<(a!=c)+(b!=d)<<" "; if((a+b)%2!=(c+d)%2) cout<<"Inf"; else { if(abs(c-a)==abs(d-b)) { if(a==c) cout<<"0 "; else cout<<"1 "; } else cout<<"2 "; } cout<<endl; } } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator