Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
一看就想到二进制。结果对了,肯定超时阿..我的思路怎么可以这样!!!!!#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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator