博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
UVA699-落叶-二叉树
阅读量:7000 次
发布时间:2019-06-27

本文共 1181 字,大约阅读时间需要 3 分钟。

1:用一根数轴,根结点是坐标index,左结点-1,右结点+1

还有一个0ms的不知道怎么过的

#include
#include
#include
#include
#include
#include
using namespace std;void caculate(int* tree, int index, int* min, int*max){ int s; cin >> s; if (s != -1) { tree[index - 1] += s; if ((index - 1) < *min) { *min = index-1; } caculate(tree, index - 1, min, max); } cin >> s; if (s != -1) { tree[index + 1] += s; if ((index +1) > *max) { *max = index+1; } caculate(tree, index + 1, min, max); }}int main(){ freopen("d:\\1.txt", "r", stdin); int MAXN = 10000; int number = 1; while (cin) { int MIDDLE = 5000; int total[MAXN]; memset(total, 0, sizeof(int) * MAXN); int s; cin >> s; if (s == -1) return 0; else { int max = MIDDLE; int min = MIDDLE; total[MIDDLE] += s; caculate(total, MIDDLE, &min, &max); cout << "Case " << number << ":" << endl; for (int i = min; i <= max; i++) if (i == min) cout << total[i]; else cout << " " << total[i]; cout << endl<

  

posted on
2017-05-10 16:34 阅读(
...) 评论(
...)

转载于:https://www.cnblogs.com/shuiyonglewodezzzzz/p/6836673.html

你可能感兴趣的文章
Kettle 中转换(transformation)的执行过程
查看>>
读书笔记-互联网思维阅读10其中一本书《自由》
查看>>
Spark入门实战系列--5.Hive(上)--Hive介绍及部署
查看>>
tomcat设置web根目录
查看>>
CF 444B(DZY Loves FFT-时间复杂度)
查看>>
OCP-1Z0-051-名称解析-文章12称号
查看>>
UVALive 4225 Prime Bases 贪心
查看>>
Oracle B-tree、位图、全文索引三大索引性能比较及优缺点汇总
查看>>
[.net 面向对象程序设计进阶] (20) 反射(Reflection)(上)利用反射技术实现动态编程...
查看>>
【转】java中float与byte[]的互转 -- 不错
查看>>
[Ogre][地形][原创]基于OgreTerrain的地形实现
查看>>
shell登录模式及其相应配置文件(转)
查看>>
Puppet常识梳理
查看>>
web.config配置文件中的configSource属性
查看>>
发现一个国内牛逼的maven仓库,速度真的太快了
查看>>
Snmp配置
查看>>
使用java实现CNN的实战
查看>>
大白话系列之C#委托与事件讲解(二)
查看>>
linux下使用 du查看某个文件或目录占用磁盘空间的大小
查看>>
iCheck表单美化插件使用方法详解(含参数、事件等)
查看>>