/ tabris /

记录详情

Accepted

/in/foo.cc: In function 'int main()':
/in/foo.cc:17:9: warning: this 'while' clause does not guard... [-Wmisleading-indentation]
 if(k<=0)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(k<=0)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 356.0 KiB
#2 Accepted 7ms 384.0 KiB
#3 Accepted 4ms 352.0 KiB
#4 Accepted 7ms 256.0 KiB
#5 Accepted 4ms 344.0 KiB
#6 Accepted 84ms 1.25 MiB
#7 Accepted 77ms 1.359 MiB
#8 Accepted 69ms 1.25 MiB
#9 Accepted 85ms 1.344 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(k<=0)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-12-10 13:49:44
评测时间
2017-12-10 13:49:44
评测机
分数
576
总耗时
346ms
峰值内存
1.359 MiB