原创 選根

有一顆有nnn個結點樹,結點被編號爲111~nnn,記根結點深度爲111,如果第iii個結點的深度是ddd,則它貢獻的價值是d×wid\times{w_i}d×wi​ ,這棵樹的價值是所有結點的價值和 求當根結點爲111~nnn時

原创 2016 年實驗班選拔試題

SUM(10 分) 題目描述:求出在 1 到 N 之間的所有整數的總和。 輸入格式:輸入包含多組測試數據。每行是一組測試數據,該數據是一個絕對值不 大於 10000 的整數 N。N=0 時,表示輸入結束。 輸出格式:對於每組測試

原创 Task On The Board

Polycarp wrote on the board a string sss containing only lowercase Latin letters (‘a’-‘z’). This string is known fo

原创 Cyclic Shifts Sorting

You are given an array a consisting of nnn integers. In one move, you can choose some index i(1≤i≤n−2)i (1≤i≤n−2)i(

原创 Swapping Places

Animals are waiting in a line, in a quarantine zone, before they can enter a hunting-free area, where they will fin

原创 Ehabs Last Corollary

Given a connected undirected graph with nnn vertices and an integer kkk, you have to either: either find an indepe

原创 Barbells

Your local gym has n barbells and m plates. In order to prepare a weight for lifting, you mustchoose a single barbe

原创 Illumination

You inherited a haunted house. Its floor plan is an nnn-by-nnn square grid with lll lamps in fixedlocations and no

原创 Birdwatching

Kiara studies an odd species of birds that travel in a very peculiar way. Their movements are best explained using

原创 Practice for KD Tree

鏈接:https://ac.nowcoder.com/acm/problem/201927 來源:牛客網 題目描述 It’s time to have a break and implement something. You ar

原创 城市排水

在一個n×nn×nn×n的方塊城市中,座標爲(i,j)(i,j)(i,j)的位置高度爲h[i,j]h[i,j]h[i,j],有mmm個排水井,分別位於(xi,yi)(x_i,y_i)(xi​,yi​) 在一場大雨中,每個位置的水都

原创 關鍵結點

一個含有nnn個結點mmm條邊的無向有權圖,判斷每個結點是否在從111到nnn的最短路徑上 輸入描述 第一行輸入一個整數TTT,代表有TTT組測試數據 對於每一組測試數據,第一行有222個整數n,mn,mn,m,接下來mmm行每行

原创 再來異或

給你具有nnn個結點n−1n-1n−1條邊的無向無環連通圖,結點編號1∼n1 \sim n1∼n,每條邊上有一個數作爲他的邊權,定義函數f(i,j)f(i,j)f(i,j)爲連接i,ji,ji,j的簡單路徑的所有邊權的異或值 求⨁

原创 Messenger Simulator

Polycarp is a frequent user of the very popular messenger. He’s chatting with his friends all the time. He has nnn

原创 Mind Control

You and your n−1n−1n−1 friends have found an array of integers a1,a2,…,ana_1,a_2,…,a_na1​,a2​,…,an​. You have decid