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)$的,需要优化,观察一下可以发现可以用过前缀和来优化. 我把 ...
随机推荐
- Java 接口中常量的思考
接口中不允许方法的实现,而抽象类是允许方法实现的及定义变量的,因此我们可以看出接口是比抽象类更高层次的抽象.如果接口可以定义变量,但是接口中的方法又都是抽象的,在接口中无法通过行为(例如set()方法 ...
- SVN的简单使用
鼠标右键 SVNCheckout 导出文件 如果想在文件里做修改:右击鼠标-SVN Commit 如果想添加文件:把想要添加的文件粘贴到文件夹中,鼠标右击-TortoiseSVN-add 如果想在添加 ...
- IOS并发编程GCD
iOS有三种多线程编程的技术 (一)NSThread (二)Cocoa NSOperation (三)GCD(全称:Grand Central Dispatch) 这三种编程方式从上到下,抽象度层次 ...
- 网站(logo,主机)
logo生成网站 http://www.uugai.com/ 花生壳 http://hsk.oray.com/download/
- css-画三角箭头
.arrow { width:; height:; content: ""; border: solid 10px #7c7; display: block; border-top ...
- Win7另存文件没有桌面的解决方法
今日一朋友保存文件随口说了一句我那个桌面找不到了...我略感惊奇,没遇到这么个情况.决定,问度娘,在此做下记录,以便以后自己或朋友查阅. 我们在网上另存一个文件,打开另存窗口,发现没有“桌面” 在收藏 ...
- 用select实现监控终端输入
首先,从man手册里找到对select函数的描述,如下: int select(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptf ...
- 绘制图形与3D增强技巧(一)----点图元
1.图元 1.点图元 glBegin(GL_POINTS); glend(); 程序:点图元的应用 #include "stdafx.h" #include<stdio.h& ...
- 【caffe】未定义函数或变量caffe_
@tag: caffe windows10上配置好caffe后(配置了matlab接口),运行caffe-master/matlab/demo/classification_demo.m报错,提示: ...
- Linux 开机 logo 修改
从内核被解压到文件系统被挂载,我们看到的经典画面是一个小企鹅.如果嫌小企鹅枯燥,我们可以把它换掉. 1. 准备图片 这里需要的是 ppm 图片,所以,我们需要把常见格式给转换为 .ppm 才能使用.c ...