| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 | #include <vector>#include <list>#include <map>#include <set>#include <deque>#include <queue>#include <stack>#include <bitset>#include <algorithm>#include <functional>#include <numeric>#include <utility>#include <sstream>#include <iostream>#include <iomanip>#include <cstdio>#include <cmath>#include <cstdlib>#include <cctype>#include <string>#include <cstring>#include <cstdio>#include <cmath>#include <cstdlib>#include <ctime>usingnamespacestd;typedeflonglongLL;#define CLR(x,y) memset((x),(y),sizeof((x)))constintmaxn = 80 + 100;intres[maxn];voidsolve(intcur,intpos){        res[pos] += cur;//add weight to res        intlson,rson;        scanf("%d",&lson);        if(~lson) solve(lson,pos - 1);//lson        scanf("%d",&rson);        if(~rson) solve(rson,pos + 1);//rson}intini(){        intv;        scanf("%d",&v);        if(v == -1)     return0;//the end of input        CLR(res,0);        solve(v,maxn/2);        return1;}voidshow_res(){        inti = 0;        while(!res[i])  ++i;        printf("%d",res[i++]);        while(res[i])                   printf(" %d",res[i++]);        puts("\n");  }intmain(){        intcntcase = 0;        while(ini()){                printf("Case %d:\n",++cntcase);                show_res();      }    return0;} | 
[2016-02-09][UVA][699][The Falling Leaves]
原文:http://www.cnblogs.com/qhy285571052/p/5185558.html