codeforces 712B. Memory and Trident】的更多相关文章

题目链接:http://codeforces.com/problemset/problem/712/B 题目大意: 给出一个字符串(由'U''D''L''R'),分别是向上.向下.向左.向右一个单位,问修改若干字符,可以回到原点.回不到原点输出 -1,可以则输出最少修改的步数. 解题思路: 如果是奇数步,则不可以回到原点 直接输出-1: 否则:分别统计出向各个方向的步数,求出 abs(U-D)+abs(L-R) 回不到原点多余的步数.然后让 剩余的步数/2 修改一处可以保证两个状态OK.(例如:…
题意:给定一个序列表示飞机要向哪个方向飞一个单位,让你改最少的方向,使得回到原点. 析:一个很简单的题,把最后的位置记录一下,然后要改的就是横坐标和纵坐标绝对值之和的一半. 代码如下: #pragma comment(linker, "/STACK:1024000000,1024000000") #include <cstdio> #include <string> #include <cstdlib> #include <cmath>…
B. Memory and Trident time limit per test:2 seconds memory limit per test:256 megabytes input:standard input output:standard output Memory is performing a walk on the two-dimensional plane, starting at the origin. He is given a string s with his dire…
题目链接: B. Memory and Trident time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Memory is performing a walk on the two-dimensional plane, starting at the origin. He is given a string s with hi…
地址:http://codeforces.com/problemset/problem/712/B 题目: B. Memory and Trident time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Memory is performing a walk on the two-dimensional plane, starti…
B. Memory and Trident 题目连接: http://codeforces.com/contest/712/problem/B Description Memory is performing a walk on the two-dimensional plane, starting at the origin. He is given a string s with his directions for motion: An 'L' indicates he should mo…
Description Memory is performing a walk on the two-dimensional plane, starting at the origin. He is given a string s with his directions for motion: An 'L' indicates he should move one unit left. An 'R' indicates he should move one unit right. A 'U'…
题目链接: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,最近感…
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…
题目链接:点击打开链接 题意: 给定n个箱子m个物品 以下n个数字表示箱子的容量 以下m个数字b1-bm 表示物品体积为2^bi大 问最多有多少个物品能够放入箱子. 思路: 贪心,先放小的,小的不能放再放大的 显然我们把n个箱子拆成二进制,然后模拟二进制减法运算. 剩下就是简单模拟 #include<stdio.h> #include<string.h> #include<iostream> #include<algorithm> #include<m…
题意:现在有一个长度为 x 的正三角形,每次可以把一条边减小,然后用最少的时间变成长度为 y 的正三角形. 析:一开始,正着想,然后有一个问题,就是第一次减小多少才能最快呢?这个好像并不好确定,然后我就可以倒着想,从一个小三角形变成一个大三角, 那么边长长的越快越好了,剩下的就暴力了. 代码如下: #pragma comment(linker, "/STACK:1024000000,1024000000") #include <cstdio> #include <st…
题意:有一个序列,然后对每一个进行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…
2019-05-19 13:25:37 加油,加油,坚持,坚持!!! 一定要逆推,才可以是最少的次数 更好的方法: https://www.cnblogs.com/ECJTUACM-873284962/p/6379014.html #include <bits/stdc++.h> using namespace std; typedef long long ll; int main() { ll x, y; scanf("%lld %lld", &x, &y…
A......................................................................................... 题目链接→Codeforces Problem 712A Memory and Crow [题意]有n个数b1, b2, ..., bn a1, a2, ..., an是通过等式ai = bi - bi + 1 + bi + 2 - bi + 3....(±)bn得到的 现给你a1, a2, ..., an这n个数,…
题意: 思路: Codeforces Round #370(Solved: 4 out of 5) A - Memory and Crow 题意:有一个序列,然后对每一个进行ai = bi - bi + 1 + bi + 2 - bi + 3.... 的操作,最后得到了a 序列,给定 a 序列,求原序列. 思路:水. #include <set> #include <map> #include <stack> #include <queue> #includ…
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 performi…
## Problem A A - Memory and Crow CodeForces - 712A 题意: 分析可得bi=ai+ai+1 题解: 分析可得bi=ai+ai+1 C++版本一 #include<bits/stdc++.h> using namespace std; ; int a[maxn]; int main(int argc, char const *argv[]) { int n; cin >> n ; ;i <= n;i ++) cin >>…
题目链接: # Name 补题状态 A Memory and Crow 已补 B Memory and Trident 已补 C Memory and De-Evolution 已补 D Memory and Scores   E Memory and Casinos   A:Memory and Crow There are n integers b1, b2, ..., bn written in a row. For all i from 1 to n, values ai are def…
本文分为两部分:"带参数的函数"和 "带修饰的函数". 浏览这篇博客前请先阅读: [NX二次开发]NX内部函数,查找内部函数的方法 带参数的函数: bool AMX__action_list_has_visible_items(struct AMX__action_list_s *)struct AMX__action_s * AMX__ask_action_by_accelerator(int,char const *)struct AMX__action_ite…
E. Memory and Casinos 题目连接: http://codeforces.com/contest/712/problem/E Description There are n casinos lined in a row. If Memory plays at casino i, he has probability pi to win and move to the casino on the right (i + 1) or exit the row (if i = n),…
地址:http://codeforces.com/problemset/problem/712/C 题目: C. Memory and De-Evolution time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Memory is now interested in the de-evolution of objects, sp…
                                         Ryouko's Memory Note Time Limit:1000MS     Memory Limit:262144KB     64bit IO Format:%I64d & %I64u Submit Status Practice CodeForces 433C Description Ryouko is an extremely forgetful girl, she could even forge…
D. Memory and Scores 题目连接: http://codeforces.com/contest/712/problem/D Description Memory and his friend Lexa are competing to get higher score in one popular computer game. Memory starts with score a and Lexa starts with score b. In a single turn, b…
C. Memory and De-Evolution 题目连接: http://codeforces.com/contest/712/problem/C 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 perfor…
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…
A. Ryouko's Memory Note 题目连接: http://www.codeforces.com/contest/434/problem/A Description Ryouko is an extremely forgetful girl, she could even forget something that has just happened. So in order to remember, she takes a notebook with her, called Ry…