求调
查看原帖
求调
657499
Ayaka_Li楼主2023/7/18 18:20
#include <iostream>
#define int long long
using namespace std;
const int mo=1024;
int T;
int res;
signed main() {
	cin>>T;
	while (T--) {
		string s="";
		char c;
		int ans=0;
		cin>>s;
		bool o=0,oo=0;
		c=getchar();
		while (c!=';') {
			if (s[s.size()-1]==']') {
				o=1;
				if (c=='[') {
					int x;
					cin>>x;
					if (s=="long[]") {
						res+=x*8;
					}
					if (s=="int[]") {
						res+=x*4;
					}
				}
				
			}
			c=getchar();
			
			if (s=="String") {
				if (c=='=') oo=1;
				if (c==',') oo=0;
				if (c>='a'&&c<='z'&&oo) ans++;
			}
			else if (c=='='&&!o) ans++;
		}
//		cout<<ans<<endl;
		if (o);
		else if (s=="int") res+=ans*4;
		else if (s=="long") res+=ans*8;
		else if (s=="String") res+=ans;
//		cout<<res<<endl;
	}
//	cout<<res<<endl;
	int KB=res/mo,
		MB =KB/mo,	
		GB=MB/mo;
//	cout<<res<<endl;
	KB%=mo;
	MB%=mo;
	GB%=mo;
	res%=mo;
	if (GB) cout<<GB<<"GB";
	if (MB)	cout<<MB<<"MB";	
	if (KB) cout<<KB<<"KB";
	if (res) cout<<res<<"B";	
	return 0;
}
2023/7/18 18:20
加载中...