【杂题】 codeforces 451D Count Good Substrings
来源:互联网 发布:curl json 格式化 编辑:程序博客网 时间:2024/05/16 08:55
一道数学题。。。刚开始看以为是后缀数组。。。然后用后缀数组做啊做啊。。调啊调啊。。。晕晕,后来发现题目中只有a和b。。。晕晕。。就挨个加与它之前相同字符且奇偶和它不同的就行了。。。晕晕。。
#include <iostream> #include <queue> #include <stack> #include <map> #include <set> #include <bitset> #include <cstdio> #include <algorithm> #include <cstring> #include <climits> #include <cstdlib>#include <cmath>#include <time.h>#define maxn 100005#define eps 1e-10#define mod 1000000009#define INF 99999999 #define lowbit(x) (x&(-x)) //#define lson o<<1, L, mid //#define rson o<<1 | 1, mid+1, R typedef long long LL;//typedef int LL;using namespace std;int pre[3][3];char s[maxn];int main(void){scanf("%s", s);int len = strlen(s);LL even = 0, odd = 0;for(int i = 0; i < len; i++) {int tmp = s[i] - 'a';pre[tmp][i%2]++;even += pre[tmp][(i%2)^1];odd += pre[tmp][i%2];}printf("%I64d %I64d\n", even, odd);return 0;}
0 0
- 【杂题】 codeforces 451D Count Good Substrings
- Codeforces 451D Count Good Substrings
- codeforces 451D Count Good Substrings 枚举
- Codeforces 451D Count Good Substrings
- Codeforces 451 D. Count Good Substrings
- CodeForces 451D Count Good Substrings
- codeforces 451 D.Count Good Substrings (思维)
- 451 D. Count Good Substrings
- Codeforces 451D Count Good Substrings(组合数学)
- Codeforces 451D Count Good Substrings (组合数)
- Codeforces 451D - Count Good Substrings(组合数学)
- CodeForces 451 D.Count Good Substrings(水~)
- Codeforces #258 (Div. 2) D. Count Good Substrings
- Codeforces Round #258 (Div. 2) D. Count Good Substrings
- Codeforces Round #258 (Div. 2)-D. Count Good Substrings
- codeforces 166 Count Good Substrings 字符串hash
- Codeforces Round #258 (Div. 2) D. Count Good Substrings —— 组合数学
- Codeforces 271D Good Substrings 暴力+Trie
- Spark 伪分布安装
- 2014-7-25-StreamReader读取txt最后一行
- 如何查看Mysql event事件是否启用
- Linux进程通信之POSIX消息队列
- struts2判断显示超过30字截取和鼠标滑过显示全部内容
- 【杂题】 codeforces 451D Count Good Substrings
- 德国而是让他和任何人提及
- hdoj 1196 Lowest Bit
- Triangle
- javascript事件机制底层实现原理
- 工作记录--jni小问题
- [转]android界面的美化Shape的使用
- System.Uri类 - 获取Url的各种属性,文件名,参数,域名,端口等等
- Ubuntu下,清屏等终端常用命令