CF1175B Catch Overflow! #6 WA帮帮忙,玄关
查看原帖
CF1175B Catch Overflow! #6 WA帮帮忙,玄关
931492
xiaohuanxiong楼主2024/3/5 21:58
#include <bits/stdc++.h>
using namespace std;
const long long N=1e5,M=4.294967295E+09;
unsigned long long t,x,head=0,ans=0,top[N]={1,1};
char in[4];
int main()
{
	cin>>t;
	while (t--)
	{
		for (int i=1;i<=3;i++)
			cin>>in[i];
		if (in[1]=='f')
		{
			cin>>x;
			head++;
			top[head]=top[head-1]*x;
		}
		if (in[1]=='a')
		{
			if (ans+top[head]>M)
			{
				cout<<"OVERFLOW!!!";
				return 0;
			}
			ans+=top[head];
		}
		if (in[1]=='e')
		{
			if (head==0)
				continue;
			else
				head--;
		}
	}
	cout<<ans;
	return 0;
}
//4294967295

2024/3/5 21:58
加载中...