1、CF #371 (Div. 2) C. Sonya and Queries map应用,也可用trie
2、总结:一开始直接用数组遍历,果断T了一发
题意:t个数,奇变1,偶变0,然后与问的匹配。
#include<bits/stdc++.h> #define max(a,b) a>b?a:b #define F(i,a,b) for (int i=a;i<=b;i++) #define mes(a,b) memset(a,b,sizeof(a)) #define INF 0x3f3f3f3f #define LL long long using namespace std; const int N=110000,MAX=1000100; LL cal(LL m) { int k=0; LL sum=0; while(m){ if((m%10)&1){ sum+=(1<<k); } m/=10; k++; } return sum; } int main() { map<LL,int>num; int t; LL m,ans; char str[5]; while(~scanf("%d",&t)) { while(t--){ scanf("%s%lld",str,&m); if(str[0]==‘+‘){ ans=cal(m); if(!num.count(ans)){ num[ans]=0; } num[ans]++; } else if(str[0]==‘-‘){ ans=cal(m); num[ans]--; } else if(str[0]==‘?‘){ ans=cal(m); printf("%d\n",num[ans]); } } } return 0; }
时间: 2024-10-05 04:55:22