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

感觉有很多朋友想的复杂了点把?下面是我的想法,至少我觉得很容易理解,AC了

Posted by yiwen028 at 2009-08-19 20:12:13 on Problem 2328
用两个变量存储可能的范围,[l,r],赋初值l为无穷小,r为无穷大,用一个bool变量ok记录是否诚实,初始值为true,然后每输入一个值,看在不在这个范围内,不在就把ok置为false,在不用管,并且接着更新范围,最后看ok是true还是false就好了~~~
                if(strcmp(line,"right on")==0)
		{
			if(x<=a.l||x>=a.r)
				ok = false;
			if(ok)
				printf("Stan may be honest\n");
			else
				printf("Stan is dishonest\n");
			a.l = INT_MIN;
			a.r = INT_MAX;
			ok = true;
		}
		else if(strcmp(line,"too high")==0){
			if(x<=a.l)
				ok=false;
			a.r=a.r<x?a.r:x;
		}
		else{
			if(x>=a.r)
				ok=false;
			a.l=a.l>x?a.l:x;
		}

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