UVa 699 The Falling Leaves
来源:互联网 发布:vua软件 编辑:程序博客网 时间:2024/06/05 06:57
#include <cstdio>#include <cstring>#include <iostream>using namespace std;const int maxn = 1e5;int sum[maxn];void build(int p) { int v; scanf("%d", &v); if (v == -1) return; sum[p] += v; build(p - 1); build(p + 1);}bool init() { int v; scanf("%d", &v); if (v == -1) return false; memset(sum, 0, sizeof(sum)); int pos = maxn / 2; sum[pos] = v; build(pos - 1); build(pos + 1); return true;}int main() {// freopen("input", "r", stdin); int i = 0; while (init()) { printf("Case %d:\n", ++i); int p = 0; while (sum[p] == 0) p++; printf("%d", sum[p++]); while (sum[p] != 0) printf(" %d", sum[p++]); printf("\n\n"); }}
0 0
- uva 699 - The Falling Leaves
- uva 699 The Falling Leaves
- uva 699 - The Falling Leaves
- UVa 699 - The Falling Leaves
- UVA 699 - The Falling Leaves
- UVa 699 - The Falling Leaves
- uva 699 The Falling Leaves
- uva-699 The Falling Leaves
- UVA 699 The Falling Leaves
- uva 699 The Falling Leaves
- UVA 699 - The Falling Leaves
- uva 699 The Falling Leaves
- uva 699 - The Falling Leaves
- UVa 699 - The Falling Leaves
- UVA 699 The Falling Leaves
- UVA - 699 The Falling Leaves
- UVA 699 The Falling Leaves
- UVA - 699 The Falling Leaves
- linux c之alarm函数的使用,定时器的实现
- ionic 禁用侧滑后退事件
- C#学习笔记之进程
- linux cd命令
- php-email格式是否正确
- UVa 699 The Falling Leaves
- 强悍的 vim —— 查找时忽略大小写
- MyBatis集合查询易错
- config file
- 集中式或者分布式服务器日志管理
- 网络知识点总结
- linux学习(一)
- 使用hibernate实现mysql中limit的查询
- IO流之File类