Codeforces 729D Sea Battle(简单思维题)】的更多相关文章

http://codeforces.com/contest/738/problem/D https://www.cnblogs.com/flipped/p/6086615.html   原 题意:海战棋游戏,长度为n的01串,1代表炸过且没有船的位置,0代表没有炸过的位置.有a个船,长度都是b,求打到一艘船至少还需要多少炸弹,并输出炸的位置. 分析:每连续的b个0就要炸一次,不然不知道有没有是不是刚好一艘船在这b个位置上面.贪心可知炸这b个的最后一个最划算.因为只要炸到一艘即可,所以答案减去a-…
Galya is playing one-dimensional Sea Battle on a 1 × n grid. In this game a ships are placed on the grid. Each of the ships consists of b consecutive cells. No cell can be part of two ships, however, the ships can touch each other. Galya doesn't know…
D. Sea Battle time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Galya is playing one-dimensional Sea Battle on a 1 × n grid. In this game a ships are placed on the grid. Each of the ships con…
D. Sea Battle time limit per test: 1 second memory limit per test :256 megabytes input: standard input output: standard output Galya is playing one-dimensional Sea Battle on a 1 × n grid. In this game a ships are placed on the grid. Each of the ships…
C. Nice Garland time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output You have a garland consisting of nn lamps. Each lamp is colored red, green or blue. The color of the ii-th lamp is sisi ('R',…
E. Superhero Battle time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output A superhero fights with a monster. The battle consists of rounds, each of which lasts exactly nn minutes. After a round…
题目链接:http://codeforces.com/problemset/problem/752/C time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Santa Claus has Robot which lives on the infinite grid and can move along its lines. He…
一个思维水题 题目大意为,一个邮递员要投递N封信,一次从邮局来回只能投递K封.求最短的投递总距离.需注意,最后一次投递后无需返回邮局. 本题思路要点: 1.最后一次投递无需返回邮局,故最后一次投递所行走距离不必乘2(即不必记录返程),所以最后一次投递的是最远的三个信: 2.画图模拟可知,我们可将正负轴的邮件分开进行处理,先处理某一轴的全部信件,在处理另一轴的全部信件: 根据上述思路可得如下代码: #include<iostream> #include<algorithm> #inc…
题面 传送门:http://codeforces.com/problemset/problem/515/C Drazil is playing a math game with Varda. Let’s define f(x)f(x)for positive integer x as a product of factorials of its digits. For example, f(135)=1!∗3!∗5!f(135)=1!∗3!∗5! First, they choose a dec…
Codeforces 题面传送门 & 洛谷题面传送门 虽说是一个 D1B,但还是想了我足足 20min,所以还是写篇题解罢( 首先注意到这个式子里涉及两个参数,如果我们选择固定一个并动态维护另一个的决策,则相当于我们要求方程 \(ax^3+bx^2+cx+d\equiv k\pmod{p}\) 的根,而这是很难维护的,因此这个思路行不通.考虑 \((x+y)(x^2+y^2)\) 的性质,我们考虑在前面添上一项 \((x-y)\),根据初中数学 \((x-y)(x+y)(x^2+y^2)=x^4…