poj3321 Apple Tree
来源:互联网 发布:php搭建网页服务器 编辑:程序博客网 时间:2024/05/19 09:15
There is an apple tree outside of kaka's house. Every autumn, a lot of apples will grow in the tree. Kaka likes apple very much, so he has been carefully nurturing the big apple tree.
The tree has N forks which are connected by branches. Kaka numbers the forks by 1 to N and the root is always numbered by 1. Apples will grow on the forks and two apple won't grow on the same fork. kaka wants to know how many apples are there in a sub-tree, for his study of the produce ability of the apple tree.
The trouble is that a new apple may grow on an empty fork some time and kaka may pick an apple from the tree for his dessert. Can you help kaka?
题解:
with tree[a] do
begin
if (l=s) and (r=s) then
begin
sum:=sum+b;
exit;
end;
m:=(l+r) div 2;
if s<=m then instree(p*2,b,s) else
if m+1<=s then instree(p*2+1,b,s);
sum:=sum+b;
end;
- poj3321---Apple Tree
- POJ3321 Apple Tree
- poj3321 Apple Tree
- POJ3321 Apple Tree
- POJ3321--Apple Tree
- POJ3321 Apple Tree
- POJ3321:Apple Tree
- POJ3321 Apple Tree
- POJ3321 Apple Tree
- POJ3321 Apple Tree
- poj3321 Apple Tree
- poj3321 Apple Tree
- poj3321 Apple Tree
- POJ3321 Apple Tree
- poj3321 Apple Tree
- poj3321 Apple Tree
- 【POJ3321】Apple Tree
- poj3321 Apple Tree
- PHP基础三:PHP7新特性&SPL
- Java千百问_07JVM架构(012)_fullGC、minorGC、magorGC有什么区别
- T-SQL:增删改
- 传感器系列之3.4继电器
- 类对象的生存周期
- poj3321 Apple Tree
- Matlab 2015a For Mac
- hdu2874 Connections between cities(LCA离线+并查集)
- 用java输出高度为n的直角三角形
- C++笔试题 String类的实现
- PHP基础四:数据库操作
- Shader Forge 的纹理
- 博客论文系列篇导航
- 第23课:使用MAT对Dump文件进行分析实战