Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

贴代码,求优化

Posted by speedcell4 at 2011-03-26 11:13:36 on Problem 1657
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:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator