【链接】 我是链接,点我呀:)

【题意】

在这里输入题意

【题解】

递归模拟就好。

【代码】

#include <bits/stdc++.h>
using namespace std; const int MAXN = 1e5; int n,cnt;
map <int,int> dic; void dfs(int x,int val){
if (val==-1) return;
dic[x]+=val;
int temp;
scanf("%d",&temp);
dfs(x-1,temp); scanf("%d",&temp);
dfs(x+1,temp);
} int main(){
//freopen("rush.txt","r",stdin);
int kase = 0;
while (~scanf("%d",&n) && n!=-1){
printf("Case %d:\n",++kase);
cnt = 1;
dfs(1,n);
map<int,int>::iterator it;
for (it = dic.begin();it != dic.end();it++){
if ( (it)!=dic.begin()) putchar(' ');
printf("%d",(*it).second);
}
puts("");
puts("");
dic.clear();
}
return 0;
}

【例题 6-10 UVA - 699】The Falling Leaves的更多相关文章

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

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

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

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

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

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

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

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

  5. uva 699 the falling leaves——yhx

    aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAA3QAAAMsCAIAAACTL3d2AAAgAElEQVR4nOx9y7GuPA4tKRADk/92T8 ...

  6. UVa 699 The Falling Leaves

    题意:给出按先序输入的一颗二叉树,分别求出从左到右的相同横坐标上的节点的权值之和 递归建树,然后用sum数组分别统计每一个横坐标上的权值之和 感觉建树都在递归递归递归= =慢慢理解吧 #include ...

  7. uva 699 The Falling Leaves dfs实现

    额,刘汝佳小白里面的配套题目. 题目求二叉树同垂直线上结点值的和. 可以用二叉树做,挺水的其实. 尝试使用dfs实现了:开一个大点的数组,根节点为最中间那点,然后读取时就可以进行和的计算了. 代码: ...

  8. uva 699 The Falling Leaves(建二叉树同一时候求和)

    本来看着挺难的.大概是由于我多瞟了一眼题解,瞬间认为简单多了.做题就得这样,多自己想想.如今是 多校联赛,然而我并不会做. .. .慢慢来,一直在努力. 分析: 题上说了做多不会超过80行.所以能够开 ...

  9. UVA 699 The Falling Leaves (递归先序建立二叉树)

    题目链接:http://acm.hust.edu.cn/vjudge/problem/19244 #include <iostream> #include <cstdio> # ...

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

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

随机推荐

  1. js---13 this call apply

    //this:this可以写在js全剧环境中(全局环境中this是window对象),this可以写在函数中,可以写在对象中, function f(){ this.name = "asdf ...

  2. 第一个WPF

    using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.T ...

  3. Autoencoders and Sparsity(二)

    In this problem set, you will implement the sparse autoencoder algorithm, and show how it discovers ...

  4. 游标 scroll

    scroll表示可随意移动游标指针(否则只能向前)

  5. spring三大框架整合

        Spring概述 Spring介绍 Spring它是一个一站式的分层轻量级框架. Spring体系结构 1.      core container a)        beans与core ...

  6. GCC中-fpic解惑(转载)

    参考: 1.<3.18 Options for Code Generation Conventions>2.<Options for Linking>3.<GCC -fP ...

  7. 基于jQuery的一组图片的滚动

    css: .displayB{display:block;}.fl{float:left;}.fr{float: right;}.posAb{position: absolute;}.posRe{po ...

  8. spring基础内容

      关注和收藏在这里   深入理解Spring框架的作用 纵览Spring , 读者会发现Spring 可以做非常多的事情. 但归根结底, 支撑Spring的仅仅是少许的基本理念, 所有的理念都可以追 ...

  9. Docker+Mongodb

    原文:Docker+Mongodb docker search mongodb docker run -d -p 2701:27017 -v /usr/mongodb/data:/data/db  - ...

  10. Direct2D 如何关闭抗锯齿

    // Each pixel is rendered if its pixel center is contained by the geometry. // D2D1_ANTIALIAS_MODE_A ...