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)$的,需要优化,观察一下可以发现可以用过前缀和来优化. 我把 ...
随机推荐
- ThinkPHP上传返回 “文件上传保存错误!”
这个问题,最终的由于 Local.class.php中的iconv('utf-8', 'gb2312' ,$filename)的问题 因为我上传的文件名中有 "-" 这个符号. i ...
- 控件(选择类): ListBox, RadioButton, CheckBox, ToggleSwitch
1.ListBox 的示例Controls/SelectionControl/ListBoxDemo.xaml <Page x:Class="Windows10.Controls.Se ...
- ftp,http,https有啥区别?
[ftp与http的区别?] HTTP(Hyper Text Transmission Protocol)是超文本传输协议,FTP(FileTransferProtocol)是文件传输协议! HTTP ...
- 【BZOJ-1507】Editor 块状链表
1507: [NOI2003]Editor Time Limit: 5 Sec Memory Limit: 162 MBSubmit: 3397 Solved: 1360[Submit][Stat ...
- 【BZOJ-4569】萌萌哒 ST表 + 并查集
4569: [Scoi2016]萌萌哒 Time Limit: 10 Sec Memory Limit: 256 MBSubmit: 459 Solved: 209[Submit][Status] ...
- 【bzoj2120】 数颜色
http://www.lydsy.com/JudgeOnline/problem.php?id=2120 (题目链接) 题意 给出一个n个数,m个询问,每次询问一个区间或修改一个数,求区间内不同的数有 ...
- Android成长日记-Android四大组件之Service组件的学习
1.什么是Service? Service是Android四大组件中与Activity最相似的组件,它们都代表可执行的程序,Service与Activity的区别在于:Service一直在后台运行,它 ...
- TCP/IP详解 笔记十一
域名服务系统(DNS) DNS:名字到IP转换:电子邮件选路信息:分布式数据库 解析器:是通过gethostbyname(3)和gethostbyaddr(3)来实现的 最常用的名字服务器是BIND ...
- android 事件传递机制 心得
看了网上很多资料. 最后我发现可以用很简单的几句话就能把它说清楚 1 每个 viewgroup 内都有 三个方法 a dispatchTouchEvent 是自己决定要不要(管他爹)要这个苹果的 一般 ...
- 通过Calendar类判断是否是周末及是否在指定时间
package time; import java.sql.Timestamp; import java.util.Calendar; import java.util.Date; public cl ...