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 blank_bird at 2011-04-04 00:04:58 on Problem 1953
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
int main(void)
{
	int n,t=0,i;
	int j;
	int sum;
	scanf("%d",&t);
	for(i=1;i<=t;i++)
	{
		sum=0;
		scanf("%d",&n);
		for(j=0;j<=(long)pow(2,n)-1;j++)
		{
			if((j&(j<<1))==0)//如果有连续的1,肯定不会肯定0;
				sum++;
		}
		printf("Scenario #%d:\n%d\n\n",i,sum);

	}
	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