题意:

给你定义一堆变量,计算一下这些变量共占了多少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[+],s1[+],s2[+];
int byt(char ss[])
{
if(strcmp(ss,"bool")==||strcmp(ss,"char")==) return ;
if(strcmp(ss,"int")==||strcmp(ss,"float")==) return ;
if(strcmp(ss,"long long")==||strcmp(ss,"double")==) return ;
if(strcmp(ss,"__int128")==||strcmp(ss,"long double")==) return ;
}
int main()
{
// ios::sync_with_stdio(false);
int T;
scanf("%d",&T);
for(int _=;_<=T;++_)
{
printf("Case #%d: ",_);
ll ans=;
int x;
scanf("%d",&x);
while(x--)
{
scanf("%s",s);
if(s[]=='l')
{
scanf("%s",s1);
strcat(s," ");
strcat(s,s1);
}
scanf("%s",s2);
int per=byt(s);
int l2=strlen(s2);
int flag=,flag1=;
for(int i=;i<l2;++i)
{
if(s2[i]=='[')
{
flag=i;
}
if(s2[i]==']')
{
flag1=i;break;
}
}
int num=;
if(flag)
{
for (int i = flag+; i<flag1; ++i) {
num = num * + (s2[i] - '');
}
ans+=num*per*1LL;
// dbg(num);
}
else ans+=(ll)per;
//dbg(ans);
} ll anss=ceil(ans*1.0/);
cout<<anss<<endl;
}
} /*
* Case #1: 1
* Case #1: 1
*/
05-11 11:29