首届全国中医药院校大学生程序设计竞赛试题.docx

上传人:h**** 文档编号:26840487 上传时间:2022-07-19 格式:DOCX 页数:12 大小:14.22KB
返回 下载 相关 举报
首届全国中医药院校大学生程序设计竞赛试题.docx_第1页
第1页 / 共12页
首届全国中医药院校大学生程序设计竞赛试题.docx_第2页
第2页 / 共12页
点击查看更多>>
资源描述

《首届全国中医药院校大学生程序设计竞赛试题.docx》由会员分享,可在线阅读,更多相关《首届全国中医药院校大学生程序设计竞赛试题.docx(12页珍藏版)》请在taowenge.com淘文阁网|工程机械CAD图纸|机械工程制图|CAD装配图下载|SolidWorks_CaTia_CAD_UG_PROE_设计图分享下载上搜索。

1、首届全国中医药院校大学生程序设计竞赛试题 Problem A: 序列的混乱程度 Time limit:1s Memory limit:128MB Description 有一个长度为n的正整数序列,一个序列的混乱程度定义为这个序列的最大值和最小值之差。请编写一个程序,计算一个序列的混乱程度。 Input 输入的第一行为一个正整数T(T=1000),表示一共有T组测试数据。 每组测试数据的第一行为一个正整数n(1=n=1000),代表这个序列的长度。第二行为n 个正整数,代表这个序列。序列中元素的大小不会超过1000。 Output 对于每个测试数据,输出一行包含一个正整数,代表对应序列的混乱程

2、度。 Sample Input 2 5 1 2 3 4 5 5 1 9 2 4 8 Sample Output 4 8 Problem B: 随机数 Time limit:1s Memory limit:128MB Description 有一个rand(n)的函数,它的作用是产生一个在0,n)的随机整数。现在有另外一个函数,它的代码如下: int random(int n,int m) return rand(n)+m; 显而易见的是函数random(n,m)可以产生任意范围的随机数。现在问题来了,如果我想要产生范围在a,b)内的一个随机数,那么对应的n,m分别为多少? Input 输入的第

3、一行为一个正整数T(T=1000),表示一共有T组测试数据。 对于每组测试数据包含两个整数a,b(a=b)。 Output 对于每组测试数据,输出一行包含两个整数n和m,两个整数中间有一个空格分隔。 Sample Input 2 0 5 1 4 Sample Output 5 0 3 1 Problem C: 完美序列 Time limit:1s Memory limit:128MB Description 已知一个长度为l的序列:b1,b2,b3,bl(1=b1=b2=b3=bl=n)。若这个序列满足每个元素是它后续元素的因子,换句话说就是对于任意的i(2=i=l)都满足bi%bi-1=0(

4、其中“%”代表求余),则称这个序列是完美的。你的任务是对于给定的n和l,计算出一共有多少序列是完美序列。由于答案很大,所有输出答案对1000000007取余后的结果。 Input 输入的第一行为一个正整数T(T=1000),表示一共有T组测试数据。 对于每组测试数据包含两个整数n,l(1=n,l=2000),分别代表序列中元素大小的最大值和序列的长度。 Output 对于每组测试数据,输出一行包含一个整数,代表答案对1000000007取余后的结果。 Sample Input 3 3 2 6 4 2 1 Sample Output 5 39 2 Problem D: 第k大数 Time lim

5、it:10s Memory limit:128MB Description 有两个序列a,b,他们的长度分别为n和m,那么将两个序列中的元素对应相乘后得到的n*m 个元素从大到小排列后的第k个元素是什么? Input 输入的第一行为一个正整数T(T=10),表示一共有T组测试数据。 每组测试数据的第一行有三个正整数n,m和k(1=n,m=100000,1=k=n*m),分别代表a 序列的长度、b序列的长度以及所求元素的下标。第二行为n个正整数代表序列a。第三行为m个正整数代表序列b。序列中所有元素的大小满足1,10000。 Output 对于每组测试数据,输出一行包含一个整数代表第k大的元素是

6、多少。 Sample Input 3 3 2 3 1 2 3 1 2 2 2 1 1 1 1 1 2 2 4 1 1 1 1 Sample Output 3 1 1 Problem E: 选房子 Time limit:1s Memory limit:128MB Description 栋栋和李剑已经大四了,想要出去找房子住。他们一共看中了n套房子。其中第i套房子已经住了ai个人了,它最多能住bi个人。栋栋和李剑想要住在一起,那么请问他们有几套可以选择的房子? Input 输入的第一行为一个正整数T(T=10),表示一共有T组测试数据。 每组测试数据的第一行有一个正整数n(1=n=100),代表

7、一共有n套房子。接下来n行,每行有两个正整数ai,bi(1=ai=bi=100),分别代表现在已经住了ai个人和最多能住bi 个人。 Output 对于每组测试数据,输出一行包含一个整数,代表他们可以选择的房子的数量。 Sample Input 2 2 1 2 1 3 3 1 10 2 10 3 10 Sample Output 1 3 Problem F: Game Time limit:1s Memory limit:128MB Description DongDong is playing a tower defense game. In this game, we have two k

8、inds of resource: money and wood. At the beginning of the game, DongDong possesses G money and no wood. Before the first round DongDong can use this money, and he can get money only by defeating the monsters. There is only one monster in each round, and DongDong can get money when the monster is dea

9、d. Meanwhile, DongDong can use this money in the current round. DongDong will lose the game when his hardiness is lower than the monsters attacking value, otherwise he will kill the monster. The money can increase the hardiness that one unit money can increase one unit hardiness. In addition, DongDo

10、ngs initial hardiness is 0. Furthermore, the money can also increase the efficiency of lumbering. The efficiency of lumbering means the number of wood that every worker can collect at each round. The initial efficiency of lumbering is W. If DongDong trains a worker in the current round, then the wor

11、ker will start working in the following rounds. DongDong will pay F money to increase one unit efficiency of lumbering or train one worker. Also, DongDong have no workers in the initial time. Only workers can lumber. Because the wood is very precious, DongDong wants to know how much wood he can get

12、at most after N rounds? Input The first line contains a positive integer T(T=1000), which means T test cases. The first line of each test case contains 4 positive integers N, F, W,G(1=N=1000, 1=F,W=10000, 1=G=1000000), which means N rounds, the cost of training a worker or increasing one unit effici

13、ency of lumbering F, the initial efficiency of lumbering W, the initial money G, respectively. Then following N lines, each line contains two positive integers Ai, Gi, Ai means the attacking value of monsters, Gi means the money that Dong Dong can get after he kills the monster. Output For each case

14、, if DongDong cannot finish N round game, please output “Its useless to collect wood.” (without quotes), otherwise print the most units of wood that DongDong can get. Sample Input 3 5 1 1 1 1 1 1 1 1 1 1 1 1 1 4 10 7 100 1 1 2 2 3 3 100000 4 3 10 7 10 10 10 10 10 20 10 Sample Output 13 Its useless t

15、o collect wood. 14 Problem G: Numbers Time limit:1s Memory limit:128MB Description DongDong is fond of numbers, and he has a positive integer P. Meanwhile, there is a rule that is: A positive integer D that satisfies the following rules: 1. D is one of the factors of P. 2. D and P have a same bit at

16、 least under the binary system. So DongDong wants to know how many positive integers D there are. Input The first line contains a positive integer T(T=1000), which means T test cases. Then comes T lines, each line contains a positive integer P(1=p=1000000000). Output For each case, print the number

17、of positive integers D that satisfies the rules. Sample Input 2 1 10 Sample Output 1 2 Problem H: Counting Words Time limit:1s Memory limit:128MB Description DongDong prefers English words to English sentences, so he wants to count the words of a sentence. Could you help him? Input The first line co

18、ntains a positive integer T(T=1000), which means T test cases. Then comes T lines, each line contains a string which combines with several words separated by spaces. Note that there may be more than one space to separate two words. Output For each case, print the number of words to the sentence. Sample Input 3 Every night in my dreams I see you I feel you That is how I know you go on Sample Output 5 6 8

展开阅读全文
相关资源
相关搜索

当前位置:首页 > 应用文书 > 策划方案

本站为文档C TO C交易模式,本站只提供存储空间、用户上传的文档直接被用户下载,本站只是中间服务平台,本站所有文档下载所得的收益归上传人(含作者)所有。本站仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。若文档所含内容侵犯了您的版权或隐私,请立即通知淘文阁网,我们立即给予删除!客服QQ:136780468 微信:18945177775 电话:18904686070

工信部备案号:黑ICP备15003705号© 2020-2023 www.taowenge.com 淘文阁