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

我的纯暴力程序难道也WA?

Posted by CydorniaKnight at 2008-11-07 15:39:41 on Problem 3252
In Reply To:看看为什么wa,跟ac程序对拍都没问题 Posted by:2008__ at 2008-08-07 22:52:14
#include<iostream>
using namespace std;

int main()
{
	int ans,l,r,i,j,judge,a,b;
	while(cin>>l>>r){
		ans=0;
		for(i=l;i<=r;++i)
		{
			a=b=0;
			j=i;
			while(j){
				if(j&1){
					++a;
				}else ++b;
				j>>=1;
			}
			if(a<=b)
				++ans;
		}
		cout<<ans<<endl;
	}
	return 0;
}

用此程序测试数据 1 2000000000
输出937891981
跟我写的程序一样啊,WHY WA?

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