D1. Balance (Easy version)(暴力&數論)
思路是開兩個map,一個用于判斷數是否出現在set中,另一個存每個數的k-mex。
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll i,j,k,n,m,t;
int main(){
ios::sync_with_stdio(0);
cin.tie(0);
map<ll,ll> f,mp;
mp[0]=1;
cin>>t;
while(t--){
string s;
cin>>s>>k;
if(s=="+")mp[k]=1;
else{
while(mp[f[k]])f[k]+=k;
cout<<f[k]<<'\n';
}
}
}