QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#163770 | #7025. How Much Memory Your Code Is Using? | ballance | AC ✓ | 23ms | 3804kb | C++23 | 1.4kb | 2023-09-04 14:59:41 | 2023-09-04 14:59:42 |
Judging History
answer
#define _CRT_SECURE_NO_WARNINGS
#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;
for (int j = i + 1; isdigit(str[j]); j++)
k = k * 10 + str[j] - '0';
return k;
}
}
return 1;
}
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;
}
这程序好像有点Bug,我给组数据试试?
详细
Test #1:
score: 100
Accepted
time: 2ms
memory: 3776kb
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];
output:
Case #1: 1 Case #2: 4
result:
ok 2 lines
Test #2:
score: 0
Accepted
time: 23ms
memory: 3804kb
input:
100 976 bool qhtwlyq; bool pwwmfdzmn; bool mcrxalwy; bool geqhbouv; bool dxv; bool tbfcpc; bool qnv; bool zgobcqpd; bool b; bool v; bool oyaisd; bool llcktmy; bool bnyp; bool hvkyjkuuix; bool briut; bool xqoea; bool pcecgpydon; bool fwmmtbgn; bool ivnhli; bool js; bool anxutjks; bool va; bool dngtl;...
output:
Case #1: 1 Case #2: 1 Case #3: 4 Case #4: 8 Case #5: 16 Case #6: 4 Case #7: 8 Case #8: 16 Case #9: 92383 Case #10: 96778 Case #11: 382422 Case #12: 750000 Case #13: 1492188 Case #14: 378907 Case #15: 707032 Case #16: 1546875 Case #17: 3 Case #18: 4 Case #19: 12 Case #20: 26 Case #21: 50 Case #22: 12...
result:
ok 100 lines