/ tabris /

记录详情

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);
         ^~~~~
# 状态 耗时 内存占用
#1 Accepted 3ms 384.0 KiB
#2 Accepted 5ms 340.0 KiB
#3 Accepted 4ms 256.0 KiB
#4 Accepted 5ms 256.0 KiB
#5 Accepted 4ms 260.0 KiB
#6 Accepted 54ms 1.336 MiB
#7 Accepted 61ms 1.336 MiB
#8 Accepted 49ms 1.301 MiB
#9 Accepted 57ms 1.363 MiB

代码

#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