Accepted
/in/foo.cc: In function 'int main()': /in/foo.cc:17:9: warning: this 'while' clause does not guard... [-Wmisleading-indentation] if(0==k)while(1); ^~~~~ /in/foo.cc:18:9: note: ...this statement, but the latter is misleadingly indented as if it is guarded by the 'while' scanf("%s",s); ^~~~~ /in/foo.cc:17:1: warning: this 'if' clause does not guard... [-Wmisleading-indentation] if(0==k)while(1); ^~ /in/foo.cc:18:9: note: ...this statement, but the latter is misleadingly indented as if it is guarded by the 'if' scanf("%s",s); ^~~~~
代码
#include <bits/stdc++.h>
typedef long long int LL;
using namespace std;
#define abs(x) ((x)>0?(x):-(x))
const int N = 1e6+7;
/*****************************************************************/
char s[N];
int k;
int main(){
int _=1,kcase=0;
scanf("%d",&_);
while(_--){
scanf("%d",&k);
if(0==k)while(1);
scanf("%s",s);
int l=strlen(s);
LL x=0,mx=0;
for(int i=l-k+1;i<l;i++){
x<<=1;
x|= s[i]=='1' ;
}
for(int i=l-k;i>=0;i--){
if(s[i]=='1') x|=1LL<<(k-1);
mx=max(mx,x);
x>>=1;
}
printf("Case #%d: %lld\n",++kcase,mx);
}
return 0;
}
信息
- 递交者
- 类型
- 递交
- 题目
- 幸运大奖
- 语言
- C++
- 递交时间
- 2017-09-11 09:41:07
- 评测时间
- 2017-09-11 09:41:07
- 评测机
- 分数
- 576
- 总耗时
- 246ms
- 峰值内存
- 1.363 MiB