/ tabris /

记录详情

Accepted


  
# 状态 耗时 内存占用
#1 Accepted 11ms 11.316 MiB
#2 Accepted 10ms 11.312 MiB
#3 Accepted 12ms 11.312 MiB
#4 Accepted 11ms 11.309 MiB
#5 Accepted 13ms 11.309 MiB
#6 Accepted 71ms 11.312 MiB
#7 Accepted 65ms 11.316 MiB
#8 Accepted 62ms 11.312 MiB
#9 Accepted 65ms 11.309 MiB

代码

#include<stdio.h>
#include<string.h>
#include<iostream>
using namespace std;
#define ll long long int
char a[11500000];
int main()
{
    int t;
    int kase=0;
    scanf("%d",&t);
    while(t--)
    {
        ll k;scanf("%lld",&k);
        memset(a,'0',sizeof(a));
        scanf("%s",a);
        ll output=0;
        ll now=0;
        int n=strlen(a);
        for(ll i=0;i<n;i++)
        {
            if(i<k)
            {
                if(a[i]=='1')
                now+=(1ll<<((k-1-i)));
            }
            else
            {
                now-=(1ll<<(k-1))*(a[i-k]-'0');
                now*=2;
                now+=1*(a[i]-'0');
            }
            output=max(output,now);
        }
        printf("Case #%d: ",++kase);
        printf("%lld\n",output);
    }
}

信息

递交者
类型
递交
题目
幸运大奖
语言
C++
递交时间
2017-09-18 20:45:57
评测时间
2017-09-18 20:45:57
评测机
分数
576
总耗时
325ms
峰值内存
11.316 MiB