QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#163760 | #7025. How Much Memory Your Code Is Using? | ballance | RE | 0ms | 0kb | C++23 | 1.4kb | 2023-09-04 14:53:36 | 2023-09-04 14:53:36 |
answer
#include<iostream>
#include<cstdio>
#include<cstring>
#include<map>
#include<string>
using namespace std;
const int tran = 1024;
int f(string str)
{
int len = str.size();
for (int i = 0; i < len; i++)
{
char e = str[i];
if (e == ';')
break;
if (e != '\n' && e != '[')
continue;
else if (e == '\n')
break;
else
{
int k = 0;
while (isdigit(e == cin.get()))
{
k = k * 10 + e - '0';
}
return k;
}
}
}
int main()
{
int t, cnt = 0, n;
scanf("%d", &t);
string str;
while (t--)
{
scanf("%d", &n);
getchar();
long long num = 0;//字节
while (n--)
{
getline(cin, str);
int len = str.size();
if (str[0] == 'b' || str[0] == 'c')//bool 一字节
{
num += f(str);
}
else if (str[0] == 'i' || str[0] == 'f')
{
num += 4 * f(str);
// cout<<num<<endl;
}
else if (str[0] == 'd') {
num += 8 * f(str);
}
else if (str[0] == '_') {
num += 16 * f(str);
}
else if (str[0] == 'l')
{
if (str[5] == 'd') {//long double 想用 substr 判断double 结果不对emm
num += 16 * f(str);
}
else {
num += 8 * f(str);
}
}
//cout<<num<<endl;
}
//cout<<num<<endl;
int ans;
if (num % tran == 0) ans = num / tran;
else ans = 1 + num / tran;
printf("Case #%d: %d\n", ++cnt, ans);
}
return 0;
}
详细
Test #1:
score: 0
Runtime Error
input:
2 8 bool a; char b; int c; long long d; __int128 e; float f; double g; long double h; 1 int a[1000];