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 1905220268 at 2009-08-12 21:09:55 on Problem 1852
#include<stdio.h>
int getnum()  //读大量数据特别快
{
    char ch;
    while (ch=getchar(),ch==10||ch==32);
    int ans=ch-48;
    while ((ch=getchar())!=EOF&&(ch>='0'&&ch<='9'))
    {
        ans*=10;
        ans+=ch-'0';
    }
    return ans;
}
int main()
{ 
    int min1,max1,min,max,i,j,m,l,n,x;
    scanf("%d",&m);
    while (m--) {
        scanf("%d%d",&l,&n);
        max=min=0;
        for (j=0;j<n;j++) {
            x=getnum();
            if(x<l-x) {min1=x;max1=l-x;}
            else {min1=l-x;max1=x;}
            min>?=min1;
            max>?=max1;
        }
        printf("%d %d\n",min,max);
    }
} 

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