这是一道水题:Problem - D1 - Codeforces
题目:
代码:
#include<iostream>
#include<set>
#include<map>
using namespace std;
typedef long long int LL ;
set<LL> st;
int main()
{
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int q;
cin >> q;
string op ;
LL x;
map<LL,LL> mp;
while(q--)
{
cin >> op >> x;
if(op == "+")st.insert(x);
else if(op == "?")
{
if(mp.count(x))
{
LL temp = x;
x = mp[x];
while(st.count(x))x += temp;
cout << x << endl;
mp[temp] = x;
continue;
}
LL temp = x;
while(st.count(x))x += temp;
mp[temp] = x;
cout << x <<endl;
}
}
return 0 ;
}