-
Notifications
You must be signed in to change notification settings - Fork 0
/
A.cpp
54 lines (46 loc) · 1022 Bytes
/
A.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define endl "\n"
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
ll binaryExponentiation(ll x,ll n){
if(n==0)
return 1;
else if(n%2 == 0) //n is even
return binaryExponentiation(x*x,n/2);
else //n is odd
return x*binaryExponentiation(x*x,(n-1)/2);
}
ll convert(ll n){
ll i=0, ans=0, rem;
while(n>0){
rem = n%10;
ans += binaryExponentiation(10,i)*(rem%2);
n /= 10;
i++;
}
return ans;
}
int main(){
fast;
ll t;
cin>>t;
map<ll,ll> mp;
while(t--){
char c;
ll a;
cin>>c>>a;
if(c=='+'){
ll temp = convert(a);
mp[temp]++;
}
else if(c=='-'){
ll temp = convert(a);
mp[temp]--;
}
else {
cout<<mp[a]<<endl;
}
}
return 0;
}