molakeser @ 2024-09-27 19:57:27
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int N = 1e6 + 5;
int t, n, x;
string s;
stack<int>p;
signed main() {
cin >> t;
while(t--) {
cin >> n;
while(n--) {
cin >> s;
if(s == "push") {
cin >> x;
p.push(x);
}
if(s == "pop") {
if(p.empty())
cout << "Empty" << endl;
else
p.pop();
}
if(s=="query") {
if(p.empty())
cout << "Anguei!" << endl;
else
cout << p.top()<< endl;
}
if(s =="size")
cout << p.size() << endl;
}
while(!p.empty())
p.pop();
}
return 0;
}
by suxiaozhou @ 2024-09-27 20:07:04
改 #define int long long
为#define int unsigned long long
by suxiaozhou @ 2024-09-27 20:11:06
题目保证
使用long long
仅能表示
所以要使用 unsigned long long
by molakeser @ 2024-09-27 20:19:04
谢谢大佬@suxiaozhou