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:大家帮我看看 为什么 总是提示Rumtime Error?

Posted by 1997000 at 2017-03-28 19:42:38 on Problem 1328
In Reply To:大家帮我看看 为什么 总是提示Rumtime Error? Posted by:ajige at 2011-09-21 11:24:02
> 
> #include <iostream>
> #include <cmath>
> #include <algorithm>
> #include <stdio.h>
> 
> #define min(a,b) ((a)<(b)?(a):(b))
> 
> using namespace std;
> 
> struct scope
> {
> 	double left;
> 	double right;
> } sscope[1000];
> 
> int cmp(struct scope x, struct scope y)
> {
> 	return x.left < y.left ? 1 : 0;
> }
> int main()
> {
> 	int n = 0, i = 0, cas = 1, omit = 0, count = 1;
> 	double location = 0 , r = 0, x = 0, y = 0;
> 
> 	while (scanf("%d %lf", &n, &r))
> 	{
> 		if (n == 0 && r == 0)
> 			break;
> 		i = 0;
> 		omit = 0;
> 		while (i < n)
> 		{
> 			scanf("%lf %lf", &x, &y);
> 			if (y > r)
> 			{
> 				printf("Case %d: -1\n", cas);
> 				omit = 1;
> 				break;
> 			}
> 			sscope[i].left = x - sqrt(pow(r, 2) - pow(y, 2));
> 			sscope[i].right = x + sqrt(pow(r, 2) - pow(y, 2));
> 
> 			i++;
> 		}
> 		if (omit != 1)
> 		{
> 			sort(sscope, sscope + n, cmp);
> 
> 			for (i = 0, count = 1; i < n - 1; i++)
> 			{
> 				location = sscope[i].right;
> 				if (location < sscope[i + 1].left)
> 				{
> 					count++;
> 					location = sscope[i].right;
> 				}
> 				else
> 					location = min(sscope[i+1].right, location);
> 			}
> 
> 			printf("Case %d: %d\n", cas, count);
> 
> 			cas++;
> 		}
> 	}
> }

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