CF399B Red and Blue Balls】的更多相关文章

题目 CF399B 洛谷RemoteJudge 思路 很容易发现,栈中靠上的蓝色球的出栈,对它下方的蓝色球没有影响. 举个例子: 第一步中靠上的蓝色球在第三步出栈了,这一过程对它下面的蓝色球(即第一步中靠下的蓝色球)没有产生影响. 这启示我们由上到下分别计算每一颗(初始状态下的)蓝色球出栈需要的步数,再相加得到答案. 不妨设\(f(x)\)表示离栈顶距离为\(x\)的蓝色球出栈需要的步数,那么上面的样例的答案即为\(f(2)+f(3)\),即"离栈顶距离为\(2\)的蓝色球出栈所需步数\(+\)…
399B - Red and Blue Balls 思路: 惊讶的发现,所有的蓝球的消除都是独立的: 对于在栈中深度为i的蓝球消除需要2^i次操作: 代码: #include <cstdio> #include <cstring> #include <iostream> #include <algorithm> using namespace std; ; int main() { // freopen("ball.in","r…
n年没有更博客:我总结出了规律,当学的东西很难得时候都去学习,没有时间写博客,只有 内容对于我这种蒟蒻友好,又让我非常闲的慌时才写博客,这种博客以后也没有价值(也有些是做完一道题有成就感写的) 最近内容就不友好,离着一篇最近的博客还有10几天,那个也是因为有成就感.... 这个是之前写好的,搬到这里来只是不会觉得太长时间没有更博客 这个题一开始我把左右搞反了 结果考试0分 反过来就对了.... 分割线 如果一个栈中最低端已经是红球就相当于不用处理栈底 假设一个栈中只有蓝球,会是多少步呢? 由打表…
题目链接:http://codeforces.com/problemset/problem/399/B 题目意思:给出 n 个只由 R 和 B 组成的字符串(由上到下排列,相当于栈),问最多可以操作多少轮.一轮包括三个步骤:(1)如果栈顶的球为 red,则弹出(注意可以弹出多个),直到遇到栈顶的球为blue  (2)将这个blue球替换为red球(只操作一次)  (3)在替换完red 球上面添加blue球,直到有 n 个球为止.当然一轮中不一定3个步骤都执行.当 n 个球都为red时,就不能再操…
#include <iostream> #include <string> using namespace std; int main(){ int n; cin >> n; string str; cin >> str; , x = ; ; i < n ; ++ i){ if(str[i] == 'B') cnt+=(x << i); } cout<<cnt<<endl; }   Codeforces Round…
思路:把字符串转化为一个二进制,遇到B就是一个数二进制中的1,答案就是这个数. #include <cstdio> #include <cstring> #include <algorithm> #define ll __int64 using namespace std; int n; ]; int main() { while(scanf("%d",&n)!=EOF) { scanf("%s",str); int k=…
因为4月初要参加微软的online.所以今天把微软的面试题拿出来做了,自己解答了题目.下面附上我的解答代码. -----------16年9月校招:  第一道题:Farthest Point(最远的整数点) 题目: #1237 : Farthest Point 时间限制:5000ms 单点时限:1000ms 内存限制:256MB 描述 Given a circle on a two-dimentional plane. Output the integral point in or on the…
刚开始学习C语言,准备在做hiho的题目的过程中来学习,在此进行记录,如果代码中有错误或者不当的地方还请指正. 时间限制:10000ms 单点时限:1000ms 内存限制:256MB 描述 The circus clown Sunny has a magic box. When the circus is performing, Sunny puts some balls into the box one by one. The balls are in three colors: red(R)…
题目1 : Magic Box 时间限制:10000ms 单点时限:1000ms 内存限制:256MB 描述 The circus clown Sunny has a magic box. When the circus is performing, Sunny puts some balls into the box one by one. The balls are in three colors: red(R), yellow(Y) and blue(B). Let Cr, Cy, Cb…
#1135 : Magic Box 时间限制:10000ms 单点时限:1000ms 内存限制:256MB 描述 The circus clown Sunny has a magic box. When the circus is performing, Sunny puts some balls into the box one by one. The balls are in three colors: red(R), yellow(Y) and blue(B). Let Cr, Cy, C…
题目1 : Magic Box 时间限制:10000ms 单点时限:1000ms 内存限制:256MB 描述 The circus clown Sunny has a magic box. When the circus is performing, Sunny puts some balls into the box one by one. The balls are in three colors: red(R), yellow(Y) and blue(B). Let Cr, Cy, Cb…
题目链接 题意 \(A+B\)个球排成一行,左边\(A\)个为红球,右边\(B\)个为蓝球. 最开始可以选择两个数\(s,t\),每次操作可以取左起第\(1\)或\(s\)或\(t\)个球.问有多少种不同的取球序列. Sample Sample Input 1 3 3 Sample Output 1 20 Explanation There are 20 ways to give 3 red balls and 3 blue balls. It turns out that all of the…
Not able to solve this problem during the contest (virtual participation). The first observation is that if we can identify $N-1$ balls of which half is blue and the other half is red, then with these $N - 1$ balls we can identify the color of the re…
题面 CF755G PolandBall and Many Other Balls 给定 \(n\) 和 \(m\).有一排 \(n\) 个球,求对于每个 \(1\le k\le m\),选出 \(k\) 个球或相邻的球不能重复的方案数. 数据范围:\(1\le n\le 10^9\),\(1\le m<2^{15}\). 路标 这题是老经典题了,前人的描述也足够充分了. 但是蒟蒻尝试了这题的 \(3\) 种做法并记在笔记中后还是忍不住去挣咕值分享给大家. 这是的三种做法对比图(从下到上依次是倍…
装饰器模式 (function(){//装饰一棵树,装饰器模式通过对对象的属性进行改变来装饰对象.需要一个设置属性的方法 var tree={}; tree.decorate=function(){ print("Make sure the tree won\'t fall"); }; tree.getDecorator=function(deco){ tree[deco].prototype=this; return new tree[deco]; }; tree.RedBalls=…
Stat2.2x Probability(概率)课程由加州大学伯克利分校(University of California, Berkeley)于2014年在edX平台讲授. PDF笔记下载(Academia.edu) Summary Bayes Theorem $$P(A_i|B)=\frac{P(B|A_i)\cdot P(A_i)}{\sum_{j}P(B|A_j)\cdot P(A_j)}$$ where $$P(B)=\sum_{j}P(B|A_j)\cdot P(A_j)$$ GRA…
J - Ball Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u Submit Status Practice HDU 4811 Appoint description:  System Crawler  (2014-10-08) Description Jenny likes balls. He has some balls and he wants to arrange them in…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2277 Change the ball Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 694    Accepted Submission(s): 272 Problem Description Garfield has three pile…
题目链接: Ball Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 2149    Accepted Submission(s): 897 Problem Description Jenny likes balls. He has some balls and he wants to arrange them in a row on t…
Table Decorations Time Limit:1000MS     Memory Limit:262144KB     64bit IO Format:%I64d & %I64u Submit Status Practice CodeForces 478C Description You have r red, g green and b blue balloons. To decorate a single table for the banquet you need exactl…
题目链接: 题目 Ball Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) 问题描述 Jenny likes balls. He has some balls and he wants to arrange them in a row on the table. Each of those balls can be one of three possible colors: red,…
Change the ball Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 593    Accepted Submission(s): 207 Problem Description Garfield has three piles of balls, each pile has unique color of following:…
C. Table Decorations time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output You have r red, g green and b blue balloons. To decorate a single table for the banquet you need exactly three balloons.…
Change the ball Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 552    Accepted Submission(s): 193 Problem Description Garfield has three piles of balls, each pile has unique color of following:…
Change the ball Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 581    Accepted Submission(s): 201 Problem Description Garfield has three piles of balls, each pile has unique color of following:…
C. Table Decorations time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output You have r red, g green and b blue balloons. To decorate a single table for the banquet you need exactly three balloons.…
1,样例说明 (1)在没有鼠标介入的情况下,这些球就像有磁性一样拼成"Google"字样. (2)在鼠标移动到其中后,小球像是受到了排斥,向画布的四周扩散,然后不规则地反弹回来. 原文出自:www.hangge.com  转载请保留原文链接:http://www.hangge.com/blog/cache/detail_1059.html 2.源码: <!DOCTYPE HTML> <html>   <head>     <style>…
前面的话 上一篇博客介绍了canvas基础用法,本文将更进一步,介绍canvas的图形处理和进阶用法 图形变换 图形变换是指用数学方法调整所绘形状的物理属性,其实质是坐标变形.所有的变换都依赖于后台的数学矩阵运算.谈到图形变换,不得不得说的三个基本变换方法就是 平移变换:translate(x,y) 旋转变换:rotate(deg) 缩放变换:scale(sx,sy) [translate()] translate(x,y):将坐标原点移动到(x,y).执行这个变换之后,坐标(0,0)会变成之前…
Jenny likes balls. He has some balls and he wants to arrange them in a row on the table. Each of those balls can be one of three possible colors: red, yellow, or blue. More precisely, Jenny has R red balls, Y yellow balls and B blue balls. He may put…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4811 题目描述: Problem Description Jenny likes balls. He has some balls and he wants to arrange them in a row on the table. Each of those balls can be one of three possible colors: red, yellow, or blue. More…