1. 程式人生 > >2016 微軟秋招(校招)線上筆試 題目234

2016 微軟秋招(校招)線上筆試 題目234

題目2 : Total Highway Distance
時間限制:10000ms
單點時限:1000ms
記憶體限制:256MB
描述
Little Hi and Little Ho are playing a construction simulation game. They build N cities (numbered from 1 to N) in the game and connect them by N-1 highways. It is guaranteed that each pair of cities are connected by the highways directly or indirectly.

The game has a very important value called Total Highway Distance (THD) which is the total distances of all pairs of cities. Suppose there are 3 cities and 2 highways. The highway between City 1 and City 2 is 200 miles and the highway between City 2 and City 3 is 300 miles. So the THD is 1000(200 + 500 + 300) miles because the distances between City 1 and City 2, City 1 and City 3, City 2 and City 3 are 200 miles, 500 miles and 300 miles respectively.

During the game Little Hi and Little Ho may change the length of some highways. They want to know the latest THD. Can you help them?

輸入
Line 1: two integers N and M.

Line 2 .. N: three integers u, v, k indicating there is a highway of k miles between city u and city v.

Line N+1 .. N+M: each line describes an operation, either changing the length of a highway or querying the current THD. It is in one of the following format.

EDIT i j k, indicating change the length of the highway between city i and city j to k miles.

QUERY, for querying the THD.

For 30% of the data: 2<=N<=100, 1<=M<=20

For 60% of the data: 2<=N<=2000, 1<=M<=20

For 100% of the data: 2<=N<=100,000, 1<=M<=50,000, 1 <= u, v <= N, 0 <= k <= 1000.

輸出
For each QUERY operation output one line containing the corresponding THD.

樣例輸入
3 5
1 2 2
2 3 3
QUERY
EDIT 1 2 4
QUERY
EDIT 2 3 2
QUERY
樣例輸出
10
14
12

題目3 : Fibonacci
時間限制:10000ms
單點時限:1000ms
記憶體限制:256MB
描述
Given a sequence {an}, how many non-empty sub-sequence of it is a prefix of fibonacci sequence.

A sub-sequence is a sequence that can be derived from another sequence by deleting some elements without changing the order of the remaining elements.

The fibonacci sequence is defined as below:

F1 = 1, F2 = 1

Fn = Fn-1 + Fn-2, n>=3

輸入
One line with an integer n.

Second line with n integers, indicating the sequence {an}.

For 30% of the data, n<=10.

For 60% of the data, n<=1000.

For 100% of the data, n<=1000000, 0<=ai<=100000.

輸出
One line with an integer, indicating the answer modulo 1,000,000,007.

樣例提示
The 7 sub-sequences are:

{a2}

{a3}

{a2, a3}

{a2, a3, a4}

{a2, a3, a5}

{a2, a3, a4, a6}

{a2, a3, a5, a6}

樣例輸入
6
2 1 1 2 2 3
樣例輸出
7

題目4 : Image Encryption
時間限制:10000ms
單點時限:1000ms
記憶體限制:256MB
描述
A fancy square image encryption algorithm works as follow:

  1. consider the image as an N x N matrix

  2. choose an integer k∈ {0, 1, 2, 3}

  3. rotate the square image k * 90 degree clockwise

  4. if N is odd stop the encryption process

  5. if N is even split the image into four equal sub-squares whose length is N / 2 and encrypt them recursively starting from step 0

Apparently different choices of the k serie result in different encrypted images. Given two images A and B, your task is to find out whether it is POSSIBLE that B is encrypted from A. B is possibly encrypted from A if there is a choice of k serie that encrypt A into B.

輸入
Input may contains multiple testcases.

The first line of the input contains an integer T(1 <= T <= 10) which is the number of testcases.

The first line of each testcase is an integer N, the length of the side of the images A and B.

The following N lines each contain N integers, indicating the image A.

The next following N lines each contain N integers, indicating the image B.

For 20% of the data, 1 <= n <= 15

For 100% of the data, 1 <= n <= 100, 0 <= Aij, Bij <= 100000000

輸出
For each testcase output Yes or No according to whether it is possible that B is encrypted from A.

樣例輸入
3
2
1 2
3 4
3 1
4 2
2
1 2
4 3
3 1
4 2
4
4 1 2 3
1 2 3 4
2 3 4 1
3 4 1 2
3 4 4 1
2 3 1 2
1 4 4 3
2 1 3 2
樣例輸出
Yes
No
Yes

相關推薦

2016 微軟線上筆試 題目234

題目2 : Total Highway Distance 時間限制:10000ms 單點時限:1000ms 記憶體限制:256MB 描述 Little Hi and Little Ho are playing a construction simu

電腦耗電量 Python --貝殼2018資料探勘工程師線上筆試題目

# -*- encoding:utf -8 -*- ''' 貝殼2018資料探勘工程師線上筆試題目(內推) 眾所周知,新款膝上型電腦都擁有自己的省電方案,現有某品牌膝上型電腦,正常工作狀態下耗電量為P1

2018年螞蟻金服前端一面總結

先簡短的介紹一下我自己吧,我是一個前端學習者,雖然我基礎知識也學了比較好,但是許久不用的知識就像流失的水,很容易就忘。在這次螞蟻金服的電話面試裡面認識到了自己很多不足的地方吧。雖然在阿里內推後的人才觀的問題裡面我覺得自己做的還是很不錯的,但是在真正的程式設計題裡面,才發現自己的程式設計其實需要更加的

Python2018持續更新...

畢業即失業,苦逼的大四狗傷不起喲。 又到了一年一度的秋招了,筆者也在拉勾,智聯,boss直聘註冊了,投了50份簡歷,3個面試,然而全掛了。 筆者痛定思痛決定將自己的經歷貼出,希望可以幫到要面試的同學。 雨軒戀原創 轉載請註明來源 雨軒戀i - 部落格園  http:/

2019.09.03貝殼部分題解

這是第一次去試水,好長好長時間沒A過題,菜的有點受不了,~~~爆零恥辱下課~~~ 題目一 描述 輸入n,m;n可以進行 -1,*2操作, 問至少多少次操作才能得到 m  樣例: 輸入 4 5 輸出 3 思路: 剛開始想複雜了!!! 簡單想:  當n小於m的時

【位元組跳動】19研發崗位第二次線上筆試純乾貨~~~

1.Bytedance Efficiency Engineering團隊在8月20日搬入了學清嘉創大廈。為了慶祝喬遷之喜,位元組君決定邀請整個EE團隊,舉辦一個大型團建遊戲-位元組跳動大闖關。可是遇到了一個問題:EE團隊共有n個人,大家都比較害羞,不善於與陌生人交流。這n個人

2016屆 阿裏巴巴研發project師C/C++筆試題--2015.08.23

int 常見 align 關於 輸出結果 strncat pair rto 存儲管理 選擇題牛客網地址題目1:http://www.nowcoder.com/test/255234/summary。 題目2:http://www.nowcoder.com/test/26

死磕 Elasticsearch 方法論 普通程序員高效精進的 10 大狠 完整版

天下 restfu fontsize elk stack inpu 人工智能 大數 out 健康 人工智能、大數據快速發展的今天,對於 TB 甚至 PB 級大數據的快速檢索已然成為剛需。Elasticsearch 作為開源領域的後起之秀,從2010年至今得到飛躍式的發展

實習生招聘 總結

今天算是正式搞完了實習生面試的所有事宜,寫一篇總結回顧一下,也趁著能回憶起來為秋招找工作留個底。按照時間順序總結。(早面的幾個公司已經快想不起來了。。。) Google (內推電面掛) 第一家面的就是最難的公司,不過找師兄內推拿到了這個電面機會感覺也還算不錯了。其實後來回憶起來,那道題目用到的演算法也並不難

[BZOJ4737][清華集訓2016]組合數問題數位 DP

Address BZOJ4737 UOJ#275 Solution 根據 Lucas 定理,當 k k

5988 2016 QingDao ICPC G 費用流

題意:一個網路流的圖,有n個點,從1~n,然後m條邊,每個點有兩個值,一個是人的數量一個是飯的數量。每條邊有容量,還有走上去可能踩斷電線的機率。問讓所有人吃到飯的前提下斷電線的最小概率是多少。  分析:使用log把乘法變加法,先建容量為1,費用為0的邊,之後建正常的邊,

2016亞洲區域賽大連站 總結[需要更加努力~]

2016亞洲區域賽 大連站總結 ACM第一塊銀牌,一個良好的開端!    週五下午就匆匆忙忙的趕去大連,路途很長,先趕到了煙臺,在從煙臺做的輪船到了大連,一路上雖然很累,但都在聊各種話題,還是比較開心愉快的。   先說些題外話,到了大連才4:30,大清早的就趕去大連海事大學

Windows 微軟雅黑Microsoft YaHei+ Monaco 字型整合方案

  擼碼字型大部分人喜歡 YaHei Consolas Hybrid,個人因為鐘意 Mac 的原因,所以在 Windows 上也更喜歡 Monaco 英文字型,無奈網上也沒有一個合適的混合字型,於

搜狐2016招聘筆試題扎金花及答案

題目描述兩個搜狐的程式設計師加了一個月班,終於放假了,於是他們決定扎金花渡過愉快的假期 。遊戲規則:共52張普通牌,牌面為2,3,4,5,6,7,8,9,10,J,Q,K,A之一,大小遞增,各四張; 每人抓三張牌。兩人比較手中三張牌大小,大的人獲勝。對於牌型的規則如下:1.三

【NOIP普及組】2016年模擬考試11.5——火柴棒等式

一、火柴棒等式(equation.cpp) 時間限制: 1 Sec  記憶體限制: 128 MB 題目描述 給你n根火柴棍,你可以拼出多少個形如“A+B=C”的等式?等式中的A、B、C是用火柴棍拼

中科軟2016筆試題總結待編輯

一、JAVA 一、執行時異常和一般異常的區別? 執行時異常: 1、是虛擬機器執行過程中遇到的“系統級”問題 2、這些問題在很多地方都能發生,比如ClassNotFound,所以沒法去一一要求程式設計師捕獲 非執行時異常,又叫錯誤: 1、是Java的類庫或是程式設計師自己寫

Hyper-V 2016 配置管理系列應用篇

主機 server rust item wsm red 遠程 isp 連接 遠程連接到Hyper-V HOST 為了日常運維管理操作,使用遠程PowerShell工作。Windows 10上安裝了RSAT(遠程管理工具 )。然後安裝了Hyper-V控制臺: 在能夠

.Net轉Java自學之路—SpringMVC框架篇四

基本 row str 出錯 edi otn basename value string SpringMVC使用Hibernate的校驗框架validation(和Hibernate沒有關系)。 頁面提交請求的參數,請求到Controller方法中,使用validation

【git之窗】十七線上問題如何拉取緊急分支

一、前提       通常使用git,都會在上線前把程式碼合併到master分支,在master上打好tag,由上線tag、回退tag確保上線正常。       例如:       上線tag: V

幾維安全Javascript程式碼混淆js加密線上使用說明

幾維安全Javascript程式碼混淆是一項線上加密服務,使用者只需將JS檔案打包成zip包,提交到加密平臺,即可完成程式碼混淆、字串加密、屬性加密、呼叫轉換等多項保護措施,提高攻擊者分析Javascript程式碼邏輯的難度,從而保護核心程式碼。 功能一、程式碼混淆 Javascript程式