题意:

给你定义一堆变量,计算一下这些变量共占了多少k内存。

题解:

按题意模拟即可,善用ceil()

//
// Created by melon on 2019/10/22.
//
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define dbg(x) cout<<#x<<"="<<x<<endl
char s[100000+50],s1[100000+50],s2[100000+50];
int byt(char ss[])
{
    if(strcmp(ss,"bool")==0||strcmp(ss,"char")==0) return 1;
    if(strcmp(ss,"int")==0||strcmp(ss,"float")==0) return 4;
    if(strcmp(ss,"long long")==0||strcmp(ss,"double")==0) return 8;
    if(strcmp(ss,"__int128")==0||strcmp(ss,"long double")==0) return 16;
}
int main()
{
 //   ios::sync_with_stdio(false);
    int T;
    scanf("%d",&T);
    for(int _=1;_<=T;++_)
    {
        printf("Case #%d: ",_);
       ll ans=0;
       int x;
       scanf("%d",&x);
       while(x--)
       {
            scanf("%s",s);
            if(s[0]=='l')
            {
                scanf("%s",s1);
                strcat(s," ");
                strcat(s,s1);
            }
            scanf("%s",s2);
            int per=byt(s);
            int l2=strlen(s2);
            int flag=0,flag1=0;
            for(int i=0;i<l2;++i)
            {
                if(s2[i]=='[')
                {
                    flag=i;
                }
                if(s2[i]==']')
                {
                    flag1=i;break;
                }
            }
            int num=0;
            if(flag)
            {
                for (int i = flag+1; i<flag1; ++i) {
                    num = num * 10 + (s2[i] - '0');
                }
                ans+=num*per*1LL;
               // dbg(num);
            }
            else ans+=(ll)per;
            //dbg(ans);
       }

       ll anss=ceil(ans*1.0/1024);
       cout<<anss<<endl;
    }
}

/*
 * Case #1: 1
 * Case #1: 1
 */
12-29 23:16