0.唔。这道题 首先要明确根节点在哪儿 初始化成pos=maxn/2;

1.因为是先序的输入方法,所以这个建树的方法很重要

 void build(int p)
 {
     int v;
     cin>>v;

     )
     {
         sum[p]+=v;
         build(p-),build(p+);
     }
 }
 #include  <iostream>
 #include <cstring>
 using namespace std;
  ;
 int sum[maxn];
 int k;
 void build(int p)
 {
     int v;
     cin>>v;

     )
     {
         sum[p]+=v;
         build(p-),build(p+);
     }

 }
 void output()
 {
     cout<<"Case "<<++k<<":"<<endl;
     ;
     ) p++;

     cout<<sum[p++];

     )
         cout<<" "<<sum[p++];
     cout<<endl<<endl;
 }
 int main()
 {
     int root;
     k=;
     while(cin>>root)
     {
         memset(sum,,sizeof(sum));
         ) break;
         ;
         sum[pos]=root;

         build(pos-);
         build(pos+);

         output();

     }
     ;
 }

Uva 699The Falling Leaves的更多相关文章

  1. UVA - 699The Falling Leaves(递归先序二叉树)

    The Falling Leaves Time Limit: 3000MS   Memory Limit: Unknown   64bit IO Format: %lld & %llu Sub ...

  2. UVA 1525 Falling Leaves

    题目链接:https://vjudge.net/problem/UVA-1525 题目链接:https://vjudge.net/problem/POJ-1577 题目大意 略. 分析 建树,然后先序 ...

  3. UVA.699 The Falling Leaves (二叉树 思维题)

    UVA.699 The Falling Leaves (二叉树 思维题) 题意分析 理解题意花了好半天,其实就是求建完树后再一条竖线上的所有节点的权值之和,如果按照普通的建树然后在计算的方法,是不方便 ...

  4. UVa 699 The Falling Leaves(递归建树)

    UVa 699 The Falling Leaves(递归建树) 假设一棵二叉树也会落叶  而且叶子只会垂直下落   每个节点保存的值为那个节点上的叶子数   求所有叶子全部下落后   地面从左到右每 ...

  5. UVA 699 The Falling Leaves (二叉树水题)

    本文纯属原创.转载请注明出处,谢谢. http://blog.csdn.net/zip_fan. Description Each year, fall in the North Central re ...

  6. UVa 699 The Falling Leaves (树水题)

    Each year, fall in the North Central region is accompanied by the brilliant colors of the leaves on ...

  7. The Falling Leaves(建树方法)

    uva 699 紫书P159 Each year, fall in the North Central region is accompanied by the brilliant colors of ...

  8. H - The Falling Leaves

    Description Each year, fall in the North Central region is accompanied by the brilliant colors of th ...

  9. UVa699 The Falling Leaves

      // UVa699 The Falling Leaves // 题意:给一棵二叉树,每个节点都有一个水平位置:左儿子在它左边1个单位,右儿子在右边1个单位.从左向右输出每个水平位置的所有结点的权值 ...

随机推荐

  1. codeforces 518B. Tanya and Postcard 解题报告

    题目链接:http://codeforces.com/problemset/problem/518/B 题目意思:给出字符串 s 和 t,如果 t 中有跟 s 完全相同的字母,数量等于或者多过 s,就 ...

  2. ORACLE、MYSQL的JDBC配置

    info.jdbc.driverClassName=oracle.jdbc.driver.OracleDriver info.jdbc.url=jdbc:oracle:thin:@192.168.18 ...

  3. (2016弱校联盟十一专场10.2) E.Coins

    题目链接 很久之前写的了,好像是对拍打表过的,推一下就行了. #include <bits/stdc++.h> using namespace std; typedef long long ...

  4. IOS - 屏幕适配

    原文:Beginning Auto Layout Tutorial in iOS 7: Part 1 感谢翻译小组成员@answer-huang(博客)热心翻译.如果您有不错的原创或译文,欢迎提交给我 ...

  5. [Android Pro] linux下查看一个文件的属性(ls,lsattr,file,stat)

    reference to : http://blog.chinaunix.net/uid-28458801-id-4615294.html 查看文件属性有多种方法,且这些方法中偏向不同,具体如下: 1 ...

  6. MVC4 @RenderBody、@RenderSection、@RenderPage、Html.RenderPartial、Html.RenderAction的作用和区别

    1. RenderBody在Razor引擎中没有了“母版页”,取而代之的是叫做“布局”的页面(_Layout.cshtml)放在了共享视图文件夹中.在这个页面中,会看到标签里有这样一条语句:@Rend ...

  7. 【转】深入Windows内核——C++中的消息机制

    上节讲了消息的相关概念,本文将进一步聊聊C++中的消息机制. 从简单例子探析核心原理 在讲之前,我们先看一个简单例子:创建一个窗口和两个按钮,用来控制窗口的背景颜色.其效果 图1.效果图  Win32 ...

  8. Java 配色方案--Dark Flash Builder - by Wilson Silva

    http://eclipsecolorthemes.org/?view=theme&id=1855

  9. 自定义Log模块

    BuildConfig.DEBUG默认为true,在为app打上SignedKeyStore之后就为false, // Log控制器 MyLoger.openDebutLog(true); MyLog ...

  10. Android Native jni 编程入门

    在某些情况下,java编程已经不能满足我们的需要,比如一个复杂的算法处理,这时候就需要用到jni(java native interface)技术: jni 其实就是java和c/cpp之间进行通信的 ...