ask恩杰2009机试题目
来源:互联网 发布:js this 编辑:程序博客网 时间:2024/05/16 10:56
Given a tree T, each node will have at most two child nodes, T has N nodes. Each node is associated with a number as weight. The weight of a tree is defined as the sum of weights of all its nodes. Given a number M (1 <= M <= N), T' is a sub tree of T that has M nodes. T' also shares the root node with T. Now you are required to find such T' which has the maximum weight.
Example
Sample input:
6
12 11 12 14 15 16
1 2
1 3
2 4
2 6
4 5
4
First line inputs an integer N, represents the number of nodes in the tree (numbered from 1 to N);
Then the second line inputs n integers represent the weight of each node;
For the next n-1 lines, each line contains two integers, specifying a link from parent -> child;
The last line contains the integer M (1 <= M <= N), which is the number of the nodes in the sub tree.
The tree in the sample may like this:
1(12)
/ /
2(11) 3(12)
/ /
4(14) 6(16)
/
5(15)
Output:
53
The output denotes the max weight of the sub tree with M nodes. The sub tree in the sample will be like (colored in red):
1(12)
/ /
2(11) 3(12)
/ /
4(14) 6(16)
/
5(15)
Note
Programming using of C/C or Java.
Sentence Similarity Measurement
Description
Given two English sentences, you are required to:
1. Devise a method to measure the similarity between them, the result score is a value between zero and one. And one means exact match, zero means totally different.
2. Implement your method with any programming language you familiar with.
3. Provide a plain text file “README.txt”, where you can describe/analyze your algorithm, list potential improvements, give your comments or anything else.
Input/Output
Input:
./yourProgramName <sentence 1> <sentence 2>
Output:
A score in [0, 1]
Example
./sen_sim “you and me.” “me and you.”
0.xxx
Note
1. Your performance will be rated based on your algorithm performance and content in “README.txt”.
2. Your method should be reasonable.
3. Computation complexity of your method should be considered.
4. If any further improvements, which you can’t implement this time, could be done to your method, you are strongly encouraged to write them down explicitly as a separate section “Potential improvements” in “README.txt”.
5. Good coding style is desirable.
6. Comments or feedbacks about this test are welcomed.
- ask恩杰2009机试题目
- ask
- Ask
- Ask price
- Ask Maclean
- ASK表
- ask for help :)
- linux 1000 ask(转)
- ask three sounds
- ask question about tabctrl
- HTK 语音识别 ASK
- ASK搜索引擎简介
- Tell, Don't Ask
- Uninstall/Remove Ask Toolbar
- dedecms 问答系统 ask
- Tell,Don’t Ask!
- Before You Ask
- matlab ASK通讯系统
- 发现一个gif2swf的小工具Easy Gif2Swf
- Win32教程33-RichEdit控件.基础知识
- 溢出要点
- asp.net生成缩略图的类
- ln 软链接和硬链接的区别
- ask恩杰2009机试题目
- ATL正则表达式库
- 清除xp登录界面显示的未读邮件
- VC6做QQ对对碰外挂程序
- 求两个数的最大公因子和最小公倍数的研究
- 页面设计原则
- myeclipse 启动优化
- SMARTFORM A5单据打印(自定义纸张/针式打印机)格式问题
- LED照明系统设计指南完全版