微軟2017預(yù)科生在線筆試

題目1 : Legendary Items

時間限制:10000ms
單點時限:1000ms
內(nèi)存限制:256MB

描述
Little Hi is playing a video game. Each time he accomplishes a quest in the game, Little Hi has a chance to get a legendary item.
At the beginning the probability is P%
. Each time Little Hi accomplishes a quest without getting a legendary item, the probability will go up Q%
. Since the probability is getting higher he will get a legendary item eventually.
After getting a legendary item the probability will be reset to ?P/(2I
)?% (?x? represents the largest integer no more than x) where I is the number of legendary items he already has. The probability will also go up Q%
each time Little Hi accomplishes a quest until he gets another legendary item.
Now Little Hi wants to know the expected number of quests he has to accomplish to get N legendary items.
Assume P
= 50, Q
= 75 and N
= 2, as the below figure shows the expected number of quests is
250%25% + 350%75%100% + 350%100%25% + 450%100%75%100% = 3.25

legendary.png
legendary.png

輸入
The first line contains three integers P
, Q
and N
.
1 ≤ N ≤ 106
, 0 ≤ P ≤ 100, 1 ≤ Q ≤ 100
輸出
Output the expected number of quests rounded to 2 decimal places.

樣例輸入
50 75 2

樣例輸出
3.25


題目2 : Tree Restoration

時間限制:10000ms
單點時限:1000ms
內(nèi)存限制:256MB

描述
There is a tree of N
nodes which are numbered from 1 to N
. Unfortunately, its edges are missing so we don't know how the nodes are connected. Instead we know:

  1. Which nodes are leaves
  2. The distance (number of edges) between any pair of leaves
  3. The depth of every node (the root's depth is 1)
  4. For the nodes on the same level, their order from left to right
    Can you restore the tree's edges with these information? Note if node u
    is on the left of node v
    , u
    's parent should not be on the right of v
    's parent.


    tree-restoration.png
    tree-restoration.png

    輸入
    The first line contains three integers N
    , M
    and K
    . N
    is the number of nodes. M
    is the depth of the tree. K is the number of leaves.
    The second line contains M
    integers A1
    , A2
    , ... AM

. Ai
represents the number of nodes of depth i
.
Then M
lines follow. The ith of the M
lines contains Ai

numbers which are the nodes of depth i
from left to right.
The (M
+3)-th line contains K
numbers L1
, L2
, ... LK

, indicating the leaves.
Then a K
× K
matrix D
follows. Dij

represents the distance between Li

and Lj

.
1 ≤ N
≤ 100
輸出
For every node from 1 to N
output its parent. Output 0 for the root's parent.

樣例輸入
8 3 5 1 3 4 1 2 3 4 5 6 7 8 3 5 6 7 8 0 3 3 3 3 3 0 2 4 4 3 2 0 4 4 3 4 4 0 2 3 4 4 2 0

樣例輸出
0 1 1 1 2 2 4 4


題目3 : Monster Killing
時間限制:10000ms
單點時限:1000ms
內(nèi)存限制:256MB
描述
In a video game Little Hi is trapped in a maze. The maze can be considered as an N × M grid. There are monsters on some cells. Each cell has one monster at most. Below is an example of a 4x5 maze. '.' represents an empty cell. 'D' represents the entrance, Little Hi's starting point. 'M' represents a normal monster. 'S' represents a special monster.

..S..
M...M
..D..
.M...
At the beginning, each cell is covered by a slate except that the slate on the entrance cell has been already removed. Each round Little Hi may either remove a slate as long as

  1. each monster has either been killed or still covered by a slate, and

  2. the cell covered by the slate is adjacent to some cell whose slate has been already removed. (Two cells are adjacent if they share a common side.)

or attack a monster as long as the slate covering it has been removed.

At the beginning Little Hi has Hp hit points and Ap attack points. Each monster also has its hit points Hi and attack points Ai. When Little Hi attacks a monster, the hit points of both sides should subtract the attack points of the other side.

For example, if Little Hi's hit points are 50 and attack points are 30. When he attacks a monster whose hit points are 25 and attack points are 10, the remaining hit points for Little Hi are 40 and the remaining hit points for the monster are -5.

When hit points are less than or equal to 0 the monster is killed.

At the beginning Little Hi has a buff called "Destruction Blade" which lasts for 5 rounds. With such buff Little Hi does not take damage when he attacks a monster. The buff vanishes after 5 rounds but can be refreshed or regained for the following 5 rounds after killing a special monster. (Note that the buff always lasts for 5 rounds after killing a special monster no matter how many rounds left before killing the monster.)

Now given the map of the maze. Can you tell whether Little Hi can kill all the monsters? If he can what is the maximum remaining hit points?

輸入
Line 1: two integers N and M. (2 ≤ N, M ≤ 6, N × M ≤ 20)

Line 2 .. N+1: M characters per line, representing the maze map.

Line N+2 .. N+K+1: two integers Hi and Ai per line, representing the hit points and attack points for each monster, from top to bottom and left to right. (3 ≤ K ≤ 7)

Line N+K+2: two integers Hp and Ap, the hit points and attack points for Little Hi.

輸出
If Little Hi can kill all the monsters and stay alive output the maximum remaining hit points. Otherwise output DEAD.

樣例解釋
Let's assume the upper left cell is (1, 1).

Round 1: remove slate (2, 3), buff remains 4 rounds

Round 2: remove slate (2, 2), buff remains 3 rounds

Round 3: remove slate (2, 1), buff remains 2 rounds

Round 4: attack monster (2, 1), take no damage, buff remains 1 round

Round 5: attack monster (2, 1), take no damage, monster killed, buff vanishes

Round 6: remove slate (2, 4)

Round 7: remove slate (4, 3)

Round 8: remove slate (1, 3)

Round 9: attack monster (1, 3), take 5 damage, HP=55

Round 10: attack monster (1, 3), take 5 damage, HP=50, monster killed, buff remains 5 rounds

Round 11: remove slate (2, 5), buff remains 4 rounds

Round 12: attack monster (2, 5) take no damage, buff remains 3 rounds

Round 13: attack monster (2, 5) take no damage, buff remains 2 rounds

Round 14: remove slate (4, 2), buff remains 1 round

Round 15: attack monster (4, 2), take no damage, buff vanishes

Round 16: attack monster (4, 2), take 5 damage, HP=45, monster killed

樣例輸入
4 5
..S..
M...M
..D..
.M...
20 5
20 5
20 5
20 5
60 10
樣例輸出
45


題目4 : Parentheses Sequence
時間限制:10000ms
單點時限:1000ms
內(nèi)存限制:256MB
描述
You are given a sequence S of parentheses. You are asked to insert into S as few parentheses as possible so that the resulting sequence T is well matched.

It's not difficult. But can you tell how many different T you can get?

Assume S = ()), you can get either (()) or ()().

輸入
One line contains the sequence S.

For 30% of the data, 1 ≤ |S| ≤ 10

For 60% of the data, 1 ≤ |S| ≤ 200

For 100% of the data, 1 ≤ |S| ≤ 1000

輸出
Output 2 integers indicating the minimum number of parentheses need to be inserted into S and the number of different T. The number of different T may be very large, so output the answer modulo 109+7.

樣例輸入
())
樣例輸出
1 2

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
  • 序言:七十年代末,一起剝皮案震驚了整個濱河市叶撒,隨后出現(xiàn)的幾起案子绝骚,更是在濱河造成了極大的恐慌,老刑警劉巖祠够,帶你破解...
    沈念sama閱讀 219,270評論 6 508
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件压汪,死亡現(xiàn)場離奇詭異,居然都是意外死亡古瓤,警方通過查閱死者的電腦和手機(jī)蛾魄,發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 93,489評論 3 395
  • 文/潘曉璐 我一進(jìn)店門,熙熙樓的掌柜王于貴愁眉苦臉地迎上來,“玉大人滴须,你說我怎么就攤上這事∵窗拢” “怎么了扔水?”我有些...
    開封第一講書人閱讀 165,630評論 0 356
  • 文/不壞的土叔 我叫張陵,是天一觀的道長朝氓。 經(jīng)常有香客問我魔市,道長,這世上最難降的妖魔是什么赵哲? 我笑而不...
    開封第一講書人閱讀 58,906評論 1 295
  • 正文 為了忘掉前任待德,我火速辦了婚禮,結(jié)果婚禮上枫夺,老公的妹妹穿的比我還像新娘将宪。我一直安慰自己,他們只是感情好橡庞,可當(dāng)我...
    茶點故事閱讀 67,928評論 6 392
  • 文/花漫 我一把揭開白布较坛。 她就那樣靜靜地躺著,像睡著了一般扒最。 火紅的嫁衣襯著肌膚如雪丑勤。 梳的紋絲不亂的頭發(fā)上,一...
    開封第一講書人閱讀 51,718評論 1 305
  • 那天吧趣,我揣著相機(jī)與錄音法竞,去河邊找鬼。 笑死强挫,一個胖子當(dāng)著我的面吹牛岔霸,可吹牛的內(nèi)容都是我干的。 我是一名探鬼主播纠拔,決...
    沈念sama閱讀 40,442評論 3 420
  • 文/蒼蘭香墨 我猛地睜開眼秉剑,長吁一口氣:“原來是場噩夢啊……” “哼!你這毒婦竟也來了稠诲?” 一聲冷哼從身側(cè)響起侦鹏,我...
    開封第一講書人閱讀 39,345評論 0 276
  • 序言:老撾萬榮一對情侶失蹤,失蹤者是張志新(化名)和其女友劉穎臀叙,沒想到半個月后略水,有當(dāng)?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體,經(jīng)...
    沈念sama閱讀 45,802評論 1 317
  • 正文 獨居荒郊野嶺守林人離奇死亡劝萤,尸身上長有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點故事閱讀 37,984評論 3 337
  • 正文 我和宋清朗相戀三年渊涝,在試婚紗的時候發(fā)現(xiàn)自己被綠了。 大學(xué)時的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片。...
    茶點故事閱讀 40,117評論 1 351
  • 序言:一個原本活蹦亂跳的男人離奇死亡跨释,死狀恐怖胸私,靈堂內(nèi)的尸體忽然破棺而出,到底是詐尸還是另有隱情鳖谈,我是刑警寧澤岁疼,帶...
    沈念sama閱讀 35,810評論 5 346
  • 正文 年R本政府宣布,位于F島的核電站缆娃,受9級特大地震影響捷绒,放射性物質(zhì)發(fā)生泄漏。R本人自食惡果不足惜贯要,卻給世界環(huán)境...
    茶點故事閱讀 41,462評論 3 331
  • 文/蒙蒙 一暖侨、第九天 我趴在偏房一處隱蔽的房頂上張望。 院中可真熱鬧崇渗,春花似錦字逗、人聲如沸。這莊子的主人今日做“春日...
    開封第一講書人閱讀 32,011評論 0 22
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽。三九已至乘碑,卻和暖如春挖息,著一層夾襖步出監(jiān)牢的瞬間,已是汗流浹背兽肤。 一陣腳步聲響...
    開封第一講書人閱讀 33,139評論 1 272
  • 我被黑心中介騙來泰國打工套腹, 沒想到剛下飛機(jī)就差點兒被人妖公主榨干…… 1. 我叫王不留,地道東北人资铡。 一個月前我還...
    沈念sama閱讀 48,377評論 3 373
  • 正文 我出身青樓电禀,卻偏偏與公主長得像,于是被迫代替她去往敵國和親笤休。 傳聞我的和親對象是個殘疾皇子尖飞,可洞房花燭夜當(dāng)晚...
    茶點故事閱讀 45,060評論 2 355

推薦閱讀更多精彩內(nèi)容

  • **2014真題Directions:Read the following text. Choose the be...
    又是夜半驚坐起閱讀 9,511評論 0 23
  • 修改虛擬磁盤大小 未分區(qū)的情況 未分區(qū)且使用卷的情況
    helphi閱讀 305評論 0 0
  • 這幾天看了Tornado的源碼,寫這篇文章以做總結(jié)店雅。本文采用Tornado v1.2版本的源碼政基,討論Tornado...
    _heqin閱讀 1,152評論 0 1
  • 許梓軒 11月12日 第14次打卡,讀了《三國演義》p109~124頁闹啦,主要講了:呂布敗走下邳城沮明,曹操在白門斬呂布...
    Dream軒閱讀 253評論 0 1
  • 2017年,我三十未到窍奋,卻感覺而立之年的壓力荐健。沒有女朋友酱畅,沒有房子,沒有金鑰匙江场,沒有工作纺酸。 作為”四沒“人員,我也...
    前山飯店閱讀 175評論 2 0