CF804B Minimum number of steps
思路:
找规律。参考了http://blog.csdn.net/harlow_cheng/article/details/71190999。
实现:
#include <iostream>
using namespace std;
const int mod = 1e9 + ;
int main()
{
string s;
cin >> s;
int n = s.length();
int cnt = ;
int sum = ;
for (int i = ; i < n; i++)
{
if (s[i] == 'a') cnt = cnt * % mod;
else sum = (sum + cnt - ) % mod;
}
cout << sum << endl;
return ;
}
CF804B Minimum number of steps的更多相关文章
- 洛谷 CF804B Minimum number of steps
嗯... 题目链接:https://www.luogu.org/problemnew/show/CF804B 这道题没有什么技巧,只是一道找规律的题. 首先看到“ab”可以换成“bba”,所以首先要确 ...
- Minimum number of steps CodeForces - 805D(签到题)
D. Minimum number of steps time limit per test 1 second memory limit per test 256 megabytes input st ...
- Codeforces Round #411 div 2 D. Minimum number of steps
D. Minimum number of steps time limit per test 1 second memory limit per test 256 megabytes input st ...
- codeforce 804B Minimum number of steps
cf劲啊 原题: We have a string of letters 'a' and 'b'. We want to perform some operations on it. On each ...
- Minimum number of steps 805D
http://codeforces.com/contest/805/problem/D D. Minimum number of steps time limit per test 1 second ...
- Codeforces 805D - Minimum number of steps
805D - Minimum number of steps 思路:简单模拟,a每穿过后面一个b,b的个数+1,当这个a穿到最后,相当于把它后面的b的个数翻倍.每个a到达最后的步数相当于这个a与它后面 ...
- Codeforces805D. Minimum number of steps 2017-05-05 08:46 240人阅读 评论(0) 收藏
D. Minimum number of steps time limit per test 1 second memory limit per test 256 megabytes input st ...
- 【codeforces 805D】Minimum number of steps
[题目链接]:http://codeforces.com/contest/805/problem/D [题意] 给你一个字符串; 里面只包括a和b; 让你把里面的"ab"子串全都去 ...
- 【推导】Codeforces Round #411 (Div. 1) B. Minimum number of steps
最后肯定是bbbb...aaaa...这样. 你每进行一系列替换操作,相当于把一个a移动到右侧. 会增加一些b的数量……然后你统计一下就行.式子很简单. 喵喵喵,我分段统计的,用了等比数列……感觉智障 ...
随机推荐
- MySQL查询去重语句
1.distinct select count(distinct CName) from Course select count(CName) from (select distinct CName ...
- MySQL集群之五大常见的MySQL高可用方案(转)
1. 概述 我们在考虑MySQL数据库的高可用的架构时,主要要考虑如下几方面: 如果数据库发生了宕机或者意外中断等故障,能尽快恢复数据库的可用性,尽可能的减少停机时间,保证业务不会因为数据库的故障而中 ...
- SQL PATINDEX检索
语法格式:PATINDEX ( '%pattern%' , expression ) 返回pattern字符串在表达式expression里第一次出现的位置,起始值从1开始算. pattern字符串在 ...
- sql 按中文排序
sql server:select * from [表名]order by [字段],[字段] collate Chinese_PRC_CS_AS_KS_WS mysql:select * from ...
- mybatis xml标签,批量插入
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE mapper PUBLIC "-/ ...
- TCP/IP协议族-----22、万维网和HTTP
- Open Flash Chart IO ERROR Loading test data Error #2032
http://blog.sina.com.cn/s/blog_6754464e0100qfvd.html Open Flash Chart 2 提示Open Flash Chart IO ERROR ...
- 怎样用fiddler2捕获移动设备上的http或者https请求
调试移动设备上的问题.看不到发送的请求和得到的响应是比較难过的,fiddler能够实现样的功能. 原理: 在PC上启动fiddler.将手持设备的网络代理改成fiddler. 这样全部的请求和响应都经 ...
- WCF探索之旅(五)——WCF与WebService的异同
前几篇文章我们简单的介绍了WCF以及怎样使用它,今天我们来讨论一下WCF和WebService的异同. 相信大多数同学跟我一样,对于WebService有所了解.并且应该说你是先听说WebServic ...
- Linux watchdog 6300esb
基本原理: Linux 自带了一个 watchdog 的实现,用于监视系统的执行,包含一个内核 watchdog module 和一个用户空间的 watchdog 程序.内核 watchdog ...