# Description

Alyona has a tree with n vertices. The root of the tree is the vertex 1. In each vertex Alyona wrote an positive integer, in the vertex i she wrote ai. Moreover, the girl wrote a positive integer to every edge of the tree (possibly, different integers on different edges).

Let's define dist(v, u) as the sum of the integers written on the edges of the simple path from v to u.

The vertex v controls the vertex u (v ≠ u) if and only if u is in the subtree of v and dist(v, u) ≤ au.

Alyona wants to settle in some vertex. In order to do this, she wants to know for each vertex v what is the number of vertices u such that vcontrols u.

# [bzoj 2819] Nim

## Description

1.随机选两个堆v,u，询问若在v到u间的路径上的石子堆中玩Nim游戏，是否有必胜策略，如果有，vfleaking将会考虑将这些石子堆作为初始局面之一，用来坑玩家。
2.把堆v中的石子数变为k。

# AIO2008 Solution

You really like ladybugs. This is fortunate, as dozens of ladybugs have recently taken up residence in your garden. Every day they emerge into the sunlight and climb your garden fence. The fence is a series of regularly spaced posts which gleam brightly in the sun. The ladybugs settle into their favourite resting spots atop these posts.

Winter is nigh and you wish to protect the ladybugs from the rain. You set out to construct a rain shelter using a single length of ribbon propped up with toothpicks. To protect all the ladybugs, the ribbon must be long enough to cover all their favourite resting spots. Ribbon is not cheap, so you wish to use the shortest length of ribbon you possibly can. A ribbon of length k will cover precisely k adjacent fence posts.

For example, on the fence in the diagram above there are two ladybugs sitting on fence post 3 and one ladybug on each of 2, 6, 7 and 9. The ribbon rain shelter must cover all the posts from 2 through to 9 inclusive, so the shortest possible length of ribbon that covers all the ladybugs is 8.

Your task is to write a program to calculate the minimum length of ribbon that will cover all the ladybugs.

# [uva 10534] Wavio Sequence

## 题目链接

UVA 10534 WAVIO SEQUENCE