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

Re:就计算一个求和,一个乘法一个减法,竟TLE了,帮我看看!

Posted by ngn999 at 2008-07-23 19:15:49 on Problem 3117
In Reply To:就计算一个求和,一个乘法一个减法,竟TLE了,帮我看看! Posted by:ngn999 at 2008-07-23 18:51:17
控制循环的不是n而是t,
再有就是测试数据里有
3 0
adsf 0
asfsa 0
sfa 0
这样的测试数据!
> #include <stdio.h>
> int main(){
> 	int t, n, i;
> 	char name[21];
> 	long sum;
> 	int score;
>     scanf("%d%d", &t,&n);
> 	while( t!=0 && n!= 0){
> 		sum = 3*n;
> 		for(i = 1; i <= n; i++){
> 			scanf("%s%d", name,&score);
> 			sum =sum - score;
> 		}
> 		printf("%d\n",sum);
> 		scanf("%d%d", &t,&n);
> 	}
> 	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