首页 > 其他 > 详细

360笔试

时间:2017-03-25 23:24:27      阅读:211      评论:0      收藏:0      [点我收藏+]

1.

偶串:

用二进制表示每个字母出现的奇偶性,在采用类似前缀和的方法求解。

#include <bits/stdc++.h>
#define maxn 100009
using namespace std;
char s[maxn];
map<int,int>mp;
int n;
int main(){
    scanf("%s",s);
    n = strlen(s);
    mp[0] = 1;
    int cur = 0;
    long long ans = 0;
    for(int i = 0; i < n; i++){
        int x = s[i] - a;
        cur ^= (1 << x);
        ans += mp[cur];
        mp[cur]++;
    }
    cout << ans << endl;
    return 0;
}

360笔试

原文:http://www.cnblogs.com/simplepaul/p/6618960.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!