【Codeforces 258D】 Count Good Substrings
【题目链接】
http://codeforces.com/contest/451/problem/D
【算法】
合并后的字符串一定是形如"ababa","babab",ab交替出现的字符串
那么,判断一段是否为回文,只需判断首尾字符是否相等即可
【代码】
#include<bits/stdc++.h>
using namespace std;
const int MAXN = 1e5 + ; int i;
long long ans1,ans2;
char s[MAXN];
long long sum[][]; int main()
{ scanf("%s",s+);
for (i = ; i <= strlen(s + ); i++)
{
sum[i%][s[i]-'a']++;
if (i % == )
{
ans1 += sum[][s[i]-'a'];
ans2 += sum[][s[i]-'a'];
} else
{
ans1 += sum[][s[i]-'a'];
ans2 += sum[][s[i]-'a'];
}
}
printf("%I64d %I64d\n",ans1,ans2); return ; }
【Codeforces 258D】 Count Good Substrings的更多相关文章
- 【codeforces 415D】Mashmokh and ACM(普通dp)
[codeforces 415D]Mashmokh and ACM 题意:美丽数列定义:对于数列中的每一个i都满足:arr[i+1]%arr[i]==0 输入n,k(1<=n,k<=200 ...
- 【POJ 2777】 Count Color(线段树区间更新与查询)
[POJ 2777] Count Color(线段树区间更新与查询) Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 4094 ...
- 【codeforces 514C】Watto and Mechanism(字符串hash)
[题目链接]:http://codeforces.com/contest/514/problem/C [题意] 给你n个字符串; 然后给你m个询问;->m个字符串 对于每一个询问字符串 你需要在 ...
- 【codeforces 768E】Game of Stones
[题目链接]:http://codeforces.com/contest/768/problem/E [题意] NIM游戏的变种; 要求每一堆石头一次拿了x个之后,下一次就不能一次拿x个了; 问你结果 ...
- 【35.29%】【codeforces 557C】Arthur and Table
time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard ou ...
- 【41.43%】【codeforces 560C】Gerald's Hexagon
time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard o ...
- 【25.64%】【codeforces 570E】Pig and Palindromes
time limit per test4 seconds memory limit per test256 megabytes inputstandard input outputstandard o ...
- 【codeforces 742B】Arpa’s obvious problem and Mehrdad’s terrible solution
time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard ou ...
- 【19.46%】【codeforces 551B】ZgukistringZ
time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard o ...
随机推荐
- windows phone数据网络开发
LINQ LINQ的全称是Language INtegrated Query,即语言集成查询.LINQ是一种查询语言,不仅可以对数字库进行查询,还可以对.net的数据集.数组.Xml文档等对象进行查询 ...
- Java基础12一IO流
1.IO流的原理 利用数据通道实现程序和数据源之间数据的的读写操作. 2.IO流分类 输入流.输出流.字节流.字符流.节点流.过滤流 3.InputStream 字节输入流 实现类FileInpu ...
- SecureCRT连接Ubuntu报The remote system refused the connection.解决方案
使用SecureCRT连接到远程Ubuntu,连接失败报The remote system refused the connection. 进入Ubuntu系统,终端中敲入以下命令: ps -ef|g ...
- 【Oracle】解锁用户
登录oracle数据库时有时会显示ERROR: ORA-28000: the account is locked,这是因为所登录的账号被锁定了. 解决办法: sqlplus / as sysdba; ...
- AI:IPPR的数学表示-CNN方法
前言: 随着超量类别PR和高精度的需求,人工特征方法局限性凸显出来,固定的特征hash压缩映射因其压缩损失.表现为特定的特征hash方法,在海量的同类数据集上近邻特性变差,而在不同类别的数据上面隔离性 ...
- win8使用教程
win8如何关机 http://product.pconline.com.cn/itbk/software/win8/1305/3301394.html shutdown.exe -s -t 00 W ...
- Entity FrameWork 操作使用详情
Entity FrameWork 是以ADO.net为基础发展的ORM解决方案. 一.安装Entity FrameWork框架 二.添加ADO.Net实体数据模型 三.EF插入数据 using Sys ...
- Java多线程--线程交替
要求:借助同步机制,sleep()方法,join()方法,实现动画显示:甲线程:1.3.5.7.9乙线程:2.4.6.8.10丙线程:a.b.c.d.emain()线程输出:线程开始,线程结束 输出结 ...
- Windows数字代码签名的作用和流程
什么是数字代码签名?数字签名代码是一种技术,它使用数字证书来识别软件的发布商和使用hash算法来确保软件的完整性.数字签名使用公共密匙签名书法被创建,它使用两种不同的密匙:公共密匙和私有密匙,我们称其 ...
- PAT_A1148#Werewolf - Simple Version
Source: PAT 1148 Werewolf - Simple Version (20 分) Description: Werewolf(狼人杀) is a game in which the ...