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 madrishing at 2013-06-15 22:53:49 on Problem 1470 and last updated at 2013-06-15 22:55:18
输入一个Q,然后有Q组(u,v)每组中间还有空格,tab等。但,稍稍想一下就能发现,Q组uv一共有Q*2个字符串,所以我们讲稿Q*2组str就可以了scanf("%s",str),然后处理每组str求得u,v
int deal(char *s,int v){
	int i,ret=0;
	if(v){
		for(i=1;s[i];++i)
			ret*=10,ret+=s[i]-'0';
	}else{
		for(i=0;s[i+1];++i)
			ret*=10,ret+=s[i]-'0';
	}
	//printf("ret=%d\n",ret);
	return ret;
}

int main(){
    .........
    int Q;
    char str[20];
    scanf("%d",&Q);
    Q<<=1;
    for(i=0;i<Q;++i){
        scanf("%s",str);
        if(i&1) v=deal(str,0),query[u].push_back(v),query[v].push_back(u);
	else u=deal(str,1);//后面那个1表示u,0表示v
    }
    ......
    return 0;
}

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