题解:AT_stpc2025_1_g Don't make zero
dongbird1646 · · 题解
题意
给定正整数
思路
显然从一个贪心的角度来想,让
感性理解一下,将
::::info[代码]
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
ll R;
ll n,x;
ll p1,f1;
char op;
int main(){
ios::sync_with_stdio(0);
cin.tie(0);
cin>>R;
while(R--){
cin>>n>>x;
p1=n;
f1=x-n-1;
for(int i=1;i<=x;i++){
cin>>op;
if(op=='+'){
cout<<p1<<endl;
p1--;
}else if(op=='-'){
cout<<f1<<endl;
f1--;
}else return 0;
}
}
return 0;
}
::::
感谢观看。