北京大學ACM比賽題目
Consider an infinite full binary search tree (see the figure below), the numbers in the Nodes are 1, 2, 3, .... In a subtree whose root Node is X, we can get the minimum number in this subtree by repeating going down the left Node until the last level, and we can also find the maximum number by going down the right Node. Now you are given some queries as "What are the minimum and maximum numbers in the subtree whose root Node is X?" Please try to find answers for there queries.
看n2實例 #Create a simulator object
set ns [new Simulator]
#Define different colors for data flows
#$ns color 1 Blue
#$ns color 2 Red
#Open the nam trace file
set nf [open out-1.nam w]
$ns namtrace-all $nf
set f0 [open out0.tr w]
set f1 [open out1.tr w]
#Define a finish procedure
proc finish {} {
global ns nf
$ns flush-trace
#Close the trace file
close $nf
#Execute nam on the trace file
exit 0
}
#Create four Nodes
set n0 [$ns Node]
set n1 [$ns Node]
set n2 [$ns Node]
set n3 [$ns Node]
#Create links between the Nodes
$ns duplex-link $n0 $n2 1Mb 10ms
CAN1.c and CAN2.c are a simple example of configuring a CAN network to
transmit and receive data on a CAN network, and how to move information to
and from CAN RAM message objects. Each C8051F040-TB CAN Node is configured
to send a message when it s P3.7 button is depressed/released, with a 0x11
to indicate the button is pushed, and 0x00 when released. Each Node also has
a message object configured to receive messages. The C8051 tests the
received data and will turn on/off the target board s LED. When one target
is loaded with CAN2.c and the other is loaded with CAN1.c, one target
board s push-button will control the other target board s LED, establishing
a simple control link via the CAN bus and can be observed directly on the
target boards.