codeforces 712A. Memory and Crow】的更多相关文章

题目链接:http://codeforces.com/problemset/problem/712/A 题目大意: 给你一个数字系列,求其满足条件的一个序列. 条件为: ai = bi - bi + 1 + bi + 2 - bi + 3.... 解题思路: 可先从后向前推,b[n]=a[n](1-n个数); b[i]=a[i]+b[i+1]-b[i+1]... 然而,你可以发现b[i]=a[i]+a[i+1],一个a数组即可解决问题. AC Code: [切记暴力不好使,还是泪奔0.0,最近感…
题意:有一个序列,然后对每一个进行ai = bi - bi + 1 + bi + 2 - bi + 3.... 的操作,最后得到了a 序列,给定 a 序列,求原序列. 析:很容易看出来,bi = ai + ai+1,然后就可以得到结果了. 代码如下: #pragma comment(linker, "/STACK:1024000000,1024000000") #include <cstdio> #include <string> #include <cs…
A. Memory and Crow time limit per test:2 seconds memory limit per test:256 megabytes input:standard input output:standard output There are n integers b1, b2, ..., bn written in a row. For all i from 1 to n, values ai are defined by the crows performi…
题目链接: A. Memory and Crow time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output There are n integers b1, b2, ..., bn written in a row. For all i from 1 to n, values ai are defined by the crows pe…
A. Memory and Crow 题目连接: http://codeforces.com/contest/712/problem/A Description There are n integers b1, b2, ..., bn written in a row. For all i from 1 to n, values ai are defined by the crows performing the following procedure: The crow sets ai ini…
题目链接:http://codeforces.com/problemset/problem/712/B 题目大意: 给出一个字符串(由'U''D''L''R'),分别是向上.向下.向左.向右一个单位,问修改若干字符,可以回到原点.回不到原点输出 -1,可以则输出最少修改的步数. 解题思路: 如果是奇数步,则不可以回到原点 直接输出-1: 否则:分别统计出向各个方向的步数,求出 abs(U-D)+abs(L-R) 回不到原点多余的步数.然后让 剩余的步数/2 修改一处可以保证两个状态OK.(例如:…
Description There are n casinos lined in a row. If Memory plays at casino \(i\), he has probability \(p_{i}\) to win and move to the casino on the right \((i + 1)\) or exit the row (if \(i = n\)), and a probability \(1 - p_{i}\) to lose and move to t…
Description Memory is now interested in the de-evolution of objects, specifically triangles. He starts with an equilateral triangle of side length \(x\), and he wishes to perform operations to obtain an equilateral triangle of side length \(y\). In a…
题目大意: 两个人玩取数游戏,第一个人分数一开始是a,第二个分数一开始是b,接下来t轮,每轮两人都选择一个[-k,k]范围内的整数,加到自己的分数里,求有多少种情况使得t轮结束后a的分数比b高.  (1 ≤ a, b ≤ 100, 1 ≤ k ≤ 1000, 1 ≤ t ≤ 100) 1.我一开始的想法是DP出玩i轮得分是j的方案数.然后状态数最多有t*(2*k*t)那么多,最坏情况下会有2e7那么多的状态,转移必须是O(1)的. dp[i][j]=sum(dp[i-1][j-k....j+k]…
$dp$,前缀和. 记$dp[i][j]$表示$i$轮结束之后,两人差值为$j$的方案数. 转移很容易想到,但是转移的复杂度是$O(2*k)$的,需要优化,观察一下可以发现可以用过前缀和来优化. 我把所有的数组全部开成$long$ $long$超时了,全改成$int$就$AC$了...... #pragma comment(linker, "/STACK:1024000000,1024000000") #include<cstdio> #include<cstring…