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,最近感觉智商被掏空】
#include<bits/stdc++.h>
using namespace std;
int a[];
int main()
{
int n,i;
while(scanf("%d",&n)!=EOF)
{
for(i=; i<=n; i++)
scanf("%d",&a[i]);
for(i=; i<n; i++)
{
printf("%d ",a[i]+a[i+]);
}
printf("%d\n",a[i]);
}
return ;
}
codeforces 712A. Memory and Crow的更多相关文章
- CodeForces 712A Memory and Crow (水题)
题意:有一个序列,然后对每一个进行ai = bi - bi + 1 + bi + 2 - bi + 3.... 的操作,最后得到了a 序列,给定 a 序列,求原序列. 析:很容易看出来,bi = ai ...
- Codeforce 712A Memory and Crow
A. Memory and Crow time limit per test:2 seconds memory limit per test:256 megabytes input:standard ...
- codeforces 712A A. Memory and Crow(水题)
题目链接: A. Memory and Crow time limit per test 2 seconds memory limit per test 256 megabytes input sta ...
- Codeforces Round #370 (Div. 2) A. Memory and Crow 水题
A. Memory and Crow 题目连接: http://codeforces.com/contest/712/problem/A Description There are n integer ...
- codeforces 712B. Memory and Trident
题目链接:http://codeforces.com/problemset/problem/712/B 题目大意: 给出一个字符串(由'U''D''L''R'),分别是向上.向下.向左.向右一个单位, ...
- Codeforces 712E Memory and Casinos
Description There are n casinos lined in a row. If Memory plays at casino \(i\), he has probability ...
- Codeforces 712C Memory and De-Evolution
Description Memory is now interested in the de-evolution of objects, specifically triangles. He star ...
- [CodeForces - 712D]Memory and Scores (DP 或者 生成函数)
题目大意: 两个人玩取数游戏,第一个人分数一开始是a,第二个分数一开始是b,接下来t轮,每轮两人都选择一个[-k,k]范围内的整数,加到自己的分数里,求有多少种情况使得t轮结束后a的分数比b高. ( ...
- CodeForces 712D Memory and Scores
$dp$,前缀和. 记$dp[i][j]$表示$i$轮结束之后,两人差值为$j$的方案数. 转移很容易想到,但是转移的复杂度是$O(2*k)$的,需要优化,观察一下可以发现可以用过前缀和来优化. 我把 ...
随机推荐
- MySql数据类型问题
1. mysql时间函数 DATE_ADD(now(), INTERVAL 1 DAY) AS tomorrow DATE_SUB(now(), INTERVAL 1 DAY) AS yesterda ...
- Swift开发小技巧--自定义转场动画
自定义转场动画 个人理解为重写了被弹出控制器的modal样式,根据自己的样式来显示modal出来的控制器 例:presentViewController(aVC, animated: true, co ...
- 哈希 poj 2002
n个点 求其中有几个正方形 n<1000 暴力4个点就不行了 大概2个点还可以 根基(x*x+y*y)%素数 hash 一下 告诉你2个点求 另外2个点 画个图推一下 重复要/2; #inclu ...
- Jquery ui autocomplete简单api
重要说明:与配置选项类似,Autocomplete插件的方法也不是直接调用,而且通过autocomplete()方法进行间接调用.例如: $("#title").autocompl ...
- C#-WinForm-菜单和工具栏
通用属性: Enabled - 指示是否启用该控件. Visiable - 确定该控件是启用还是隐藏的. Checked - 指示组件是否处于选中状态. 点击事件. 工具箱→菜单和工具栏 1.Cont ...
- this action could not be completed.try again登陆appstore错误提示
今天升级10.11后登陆appstore的时候发现报错了: this action could not be completed.try again 解决办法,终端敲入: sudo mkdir -p ...
- UIScrollView实现图片轮播器及其无限循环效果
图片轮播器: 一.实现效果 实现图片的自动轮播 二.实现代码 storyboard中布局 代码: 1 #import "YYViewController.h" ...
- BZOJ 1853: [Scoi2010]幸运数字
1853: [Scoi2010]幸运数字 Time Limit: 2 Sec Memory Limit: 64 MBSubmit: 2117 Solved: 779[Submit][Status] ...
- 【BZOJ-2962】序列操作 线段树 + 区间卷积
2962: 序列操作 Time Limit: 50 Sec Memory Limit: 256 MBSubmit: 678 Solved: 246[Submit][Status][Discuss] ...
- VS生成事件宏$(TargetPath) 一直为空
在接手以前的项目的时候,遇见一个很奇怪的问题,我在一个项目的类库里面,使用了生成实现,如下: copy /Y $(TargetPath) $(SolutionDir)..\ copy /Y $(Tar ...