AC日记——Red and Blue Balls codeforces 399b
思路:
惊讶的发现,所有的蓝球的消除都是独立的;
对于在栈中深度为i的蓝球消除需要2^i次操作;
代码:
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm> using namespace std; long long ans=; int main()
{
// freopen("ball.in","r",stdin);
// freopen("ball.out","w",stdout);
int n;char ch[];
long long count=;
scanf("%d",&n);
scanf("%s",ch);
for(int i=;i<n;i++)
{
if(ch[i]=='B') ans+=count;
count<<=;
}
printf("%lld\n",ans);
return ;
}
AC日记——Red and Blue Balls codeforces 399b的更多相关文章
- codeforces 399B. Red and Blue Balls 解题报告
题目链接:http://codeforces.com/problemset/problem/399/B 题目意思:给出 n 个只由 R 和 B 组成的字符串(由上到下排列,相当于栈),问最多可以操作多 ...
- Codeforces Round #233 (Div. 2) B. Red and Blue Balls
#include <iostream> #include <string> using namespace std; int main(){ int n; cin >&g ...
- cf B Red and Blue Balls
思路:把字符串转化为一个二进制,遇到B就是一个数二进制中的1,答案就是这个数. #include <cstdio> #include <cstring> #include &l ...
- AC日记——Sagheer and Nubian Market codeforces 812c
C - Sagheer and Nubian Market 思路: 二分: 代码: #include <bits/stdc++.h> using namespace std; #defin ...
- AC日记——Andryusha and Colored Balloons codeforces 780c
C - Andryusha and Colored Balloons 思路: 水题: 代码: #include <cstdio> #include <cstring> #inc ...
- AC日记——Little Elephant and Shifts codeforces 221e
E - Little Elephant and Shifts 思路: 一次函数线段树(疯狂debug): b不断循环左移,判断每次最小的|i-j|,a[i]=b[j]: 仔细观察发现,每个bi移动时, ...
- AC日记——Little Elephant and Problem codeforces 221c
221C 思路: 水题: 代码: #include <cstdio> #include <cstring> #include <iostream> #include ...
- AC日记——Little Elephant and Array codeforces 221d
221D - Little Elephant and Array 思路: 莫队: 代码: #include <cmath> #include <cstdio> #include ...
- AC日记——Little Elephant and Numbers codeforces 221b
221B - Little Elephant and Numbers 思路: 水题: 代码: #include <cmath> #include <cstdio> #inclu ...
随机推荐
- css如何选择相同class下的第一个class元素和最后一个元素?
如图,如果像选择类名为 class="exerciseInfo" 中的第一个和最后一个div,做法如下: 选择第一个类名: .exerciseInfo: nth-of-type ...
- 如何使用 window.open() 处理ajax请求返回的url: 在本页面打开并防止浏览器拦截
ajax请求中用window.open()打开请求返回url(例如实现下载功能时),可能会因为跨域问题导致浏览器拦截 解决办法是:在请求前,打开一个窗口,请求成功后将返回的url直接赋值给该窗口的hr ...
- RDMA
什么是RDMA? 来源 https://blog.csdn.net/u011459120/article/details/78469098 1. 概述 RDMA是Remote Direct Memor ...
- BZOJ1558 [JSOI2009]等差数列 【线段树】
题目链接 BZOJ1558 题解 等差数列,当然是差分一下 差分值相同的连续位置形成等差数列,我们所选的两个等差数列之间可以有一个位置舍弃 例如: \(1 \; 2 \; 3 \; 6 \; 8 \; ...
- redux的基本概念
1. State 应用的数据,即状态 2. Action 一个纯对象,携带这个操作的类型和数据信息,主要是用来进行传递信息,如下所示: const action = { type: 'ADD_TODO ...
- 用spring的@Validated注解和org.hibernate.validator.constraints.*的一些注解在后台完成数据校验
这个demo主要是让spring的@Validated注解和hibernate支持JSR数据校验的一些注解结合起来,完成数据校验.这个demo用的是springboot. 首先domain对象Foo的 ...
- nginx对指定目录做代理
环境介绍 web1,作为前端端服务器,访问地址是http://192.168.1.1,要将http://192.168.1.1/bbs的请求交给web2.在web1的网站根目录下并没有bbs目录 we ...
- [05] call by sharing || 共享参数
转: https://segmentfault.com/a/1190000005177386 众所周知,JavaScript中参数是按值传递的.与访问变量不同,基本类型和引用类型的参数在传递时都如同变 ...
- es6+最佳入门实践(12)
12.class基础用法和继承 12.1.class基础语法 在es5中,面向对象我们通常写成这样 function Person(name,age) { this.name = name; this ...
- 160多条Windows 7 “运行”命令
160多条Windows 7 “运行”命令: 删除或更改应用程序 = control appwiz.cpl 添加设备 = devicepairingwizard 蓝牙文件传输 = fsquirt ...