Codeforces 877C Slava and tanks(思维)】的更多相关文章

题目链接:http://codeforces.com/problemset 题目大意:有n个格子,某些格子里可能有一个或多个坦克,但不知道具体位置,每个坦克被轰炸一次就会移动到相邻的格子里(第1个格子只能往第2个格子移动,第n个格子只能往第n-1个格子移动),被轰炸两次就会报废,问最少需要轰炸几次才能保证所有坦克全部报废,请输出轰炸的位置. 解题思路:其实就是先把1~n所有的偶数输出,再输出所有的奇数,再输出所有的偶数.因为通过题意可以知道我们需要让坦克出现在任意格子中都要被轰炸两次,才能保证摧…
http://codeforces.com/problemset/problem/877/C   C. Slava and tanks time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Slava plays his favorite game "Peace Lightning". Now he is flying a…
C. Slava and tanks time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Slava plays his favorite game "Peace Lightning". Now he is flying a bomber on a very specific map. Formally, map is…
[链接] 我是链接,点我呀:) [题意] 有n个位置,每个位置都可能有不定数量的tank; 你每次可以选择一个位置投掷炸弹. 并且,这个位置上的所有tank都会受到你的攻击. 并且失去一点体力. 然后它们可能会往左走一格,或者往右走一格. 每个tank的体力都为2. 问你打掉所有的tank最坏情况要多少次轰炸操作.然后输出所有的轰炸位置. [题解] 在2,4,6...轰炸 然后在1,3,5...轰炸 最后在2,4,6轰炸. 可以保证每个tank都被炸死. [代码] #include <bits/…
Slava plays his favorite game "Peace Lightning". Now he is flying a bomber on a very specific map. Formally, map is a checkered field of size 1 × n, the cells of which are numbered from 1 to n, in each cell there can be one or several tanks. Sla…
Police Recruits Time Limit: 1000MS   Memory Limit: 262144KB   64bit IO Format: %I64d & %I64u Submit Status Description The police department of your city has just started its journey. Initially, they don’t have any manpower. So, they started hiring n…
codeforces 895B XK Segments 题目大意: 寻找符合要求的\((i,j)\)对,有:\[a_i \le a_j \] 同时存在\(k\),且\(k\)能够被\(x\)整除,\(k\)满足:\[a_i \le k \le a_j\] 思路: 整体数组排序,对于当前\(a_i\)寻找符合条件的\(a_j\)的最大值和最小值 有:\[(a_i-1)/x+k=a_j/x\] 所以可以通过二分查找获得,这里我寻找\(((a_i-1)/x+k)*x\)为下界,\(((a_i-1)/x…
codeforces 893D Credit Card 题目大意: 有一张信用卡可以使用,每天白天都可以去给卡充钱.到了晚上,进入银行对卡的操作时间,操作有三种: 1.\(a_i>0\) 银行会给卡充入\(a_i\)元 2.\(a_i<0\) 银行从卡中扣除\(a_i\)元 3.\(a_i=0\) 银行对你的卡进行评估,违背了规则就无权再使用此卡 规则1:卡内的余额不得超过\(d\)元 规则2:当\(a_i=0\)时,卡内的余额不能是负数 现在问为了维持信用的平衡,最少去银行几次.(去一次,充…
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',…
Alyona and Spreadsheet 这就是一道思维的题,谈不上算法什么的,但我当时就是不会,直到别人告诉了我,我才懂了的.唉 为什么总是这么弱呢? [题目链接]Alyona and Spreadsheet &题意: 给一n*m的表,之后给T个询问,每个询问是r1和r2,问从r1行到r2行(包括这2行)是否至少有一列是非递减的? &题解: 可以把给的n*m表处理一下,处理成b[i][j]数组,存的是第j列递增开始的位置是第几行. 这样,只有b中第r2行最小的小于r1就行了,否则就是…