第五届黑龙江大学生程序竞赛题目
- 格式:doc
- 大小:39.00 KB
- 文档页数:9
bupt程序设计竞赛题目
BUPT程序设计竞赛题目可以涉及各种编程语言和算法题目。
以下是一些可能的BUPT程序设计竞赛题目示例:
1. 编写一个程序,接受一个整数输入n,计算并输出从1到n 的所有整数的平方。
2. 设计一个程序,接受一个字符串输入,统计并输出字符串中每个字符出现的次数。
3. 编写一个程序,实现一个简单的计算器,可以进行加减乘除四则运算。
4. 设计一个程序,接受一个整数输入n,计算并输出斐波那契数列的第n个数。
5. 编写一个程序,实现一个简单的图书管理系统,包括图书的增删改查功能。
6. 设计一个程序,接受一个字符串输入,判断该字符串是否为
回文字符串。
7. 编写一个程序,实现一个简单的迷宫游戏,玩家需要找到出
口并避开障碍物。
8. 设计一个程序,接受一个整数输入n,计算并输出n的阶乘。
9. 编写一个程序,实现一个简单的日程管理系统,可以添加、
删除和查询日程。
10. 设计一个程序,接受一个整数输入n,判断n是否为素数。
以上只是一些示例题目,实际的BUPT程序设计竞赛题目可能更
加复杂和具体。
在竞赛中,参赛者需要根据题目要求,使用合适的
编程语言和算法进行解题,并确保程序的正确性和效率。
2024年9月GESP编程能力认证C++等级考试试卷五级真题(含答案) 一、单选题(每题2分,共30分)。
1. 下面关于链表和数组的描述,错误的是()。
A. 数组大小固定,链表大小可动态调整。
B. 数组支持随机访问,链表只能顺序访问。
C. 存储相同数目的整数,数组比链表所需的内存多。
D. 数组插入和删除元素效率低,链表插入和删除元素效率高。
2. 通过()操作,能完成在双向循环链表结点p之后插入结点s的功能(其中next域为结点的直接后继,prev域为结点的直接前驱)。
A. p->next->prev =s;s->prev =p;p->next =s;s->next =p->next;B. p->next->prev =s;p->next =s;s->prev =p;s->next =p->next;C. s->prev =p;s->next =p->next;p->next =s;p->next->prev =s;D. s->next =p->next;p->next->prev =s;s->prev =p;p->next =s;3. 对下面两个函数,说法错误的是()。
int sumA(int n){int res =0;for(int i =1;i <=n;i++){res +=i;}return res;}int sumB(int n){if(n ==1)return 1;int res =n + sumB(n - 1);return res;}A. sumA体现了迭代的思想。
B. SumB采用的是递归方式。
C. SumB函数比SumA的时间效率更高。
D. 两个函数的实现的功能相同。
4. 有如下函数fun,则fun(20, 12)的返回值为()。
2024年3月青少年软件编程Python等级考试试卷五级真题(含答案解析)分数:100 题数:38一、单选题(共25题,共50分)。
1. 以下代码的输出结果是?()nums = list(range(100, 201))print(nums[::10])A. [100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200]B. [100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 200]C. [100, 111, 122, 133, 144, 155, 166, 177, 188, 199]D. [199, 188, 177, 166, 155, 144, 133, 122, 111, 100]标准答案:A。
试题解析:list(range(100, 201)) 表示包含 100 到 200 一百个整数的列表,而 nums[::10] 表示从开头(即索引 0)开始,每隔 10 个元素取一个数,因此输出结果为 [100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200]。
2. 以下代码的输出结果是?()def count_odd_numbers(n):return len([num for num in range(n) if num % 2 != 0])print(count_odd_numbers(20))A. 5B. 8C. 10D. 15标准答案:C。
试题解析:range(n) 表示包含 0 到 n-1 之间的所有整数,而 [num for num in range(n) if num % 2 != 0] 表示从 0 到 n-1 中选出所有奇数,而这些奇数正好有 1, 3, 5, 7, 9, 11, 13, 15,17,19所以输出结果为 10。
3. 以下代码的输出结果是?()for i in range(5):print(' '*(5-i) + '*'*(2*i+1))A. 错误,代码无法运行。
2024年3月GESP编程能力认证C++等级考试五级真题(含答案)一、单选题(每题2分,共30分)。
1.唯一分解定理描述的内容是()。
A. 任意整数都可以分解为素数的乘积B. 每个合数都可以唯一分解为一系列素数的乘积C. 两个不同的整数可以分解为相同的素数乘积D. 以上都不对2.贪心算法的核心思想是()。
A. 在每一步选择中都做当前状态下的最优选择B. 在每一步选择中都选择局部最优解C. 在每一步选择中都选择全局最优解D. 以上都对3.下面的C++代码片段用于计算阶乘。
请在横线处填入(),实现正确的阶乘计算。
4.下面的代码片段用于在双向链表中删除一个节点。
请在横线处填入(),使其能正确实现相应功能。
5.辗转相除法也被称为()。
A. 高斯消元法B. 费马定理C. 欧几里德算法D. 牛顿迭代法6.下面的代码片段用于计算斐波那契数列,该代码的时间复杂度是()。
7.下面的代码片段用于将两个高精度整数进行相加。
请在横线处填入(),使其能正确实现相应功能。
8.给定序列1,3,6,9,17,31,39,52,61,79,81,90,96。
使用以下代码进行二分查找查找元素82时,需要循环多少次,即最后输出的times值为()。
9.下面的代码片段用于判断一个正整数是否为素数。
请对以下代码进行修改,使其能正确实现相应功能()。
10.在埃拉托斯特尼筛法中,要筛选出不大于n的所有素数,最外层循环应该遍历什么范围()。
11.素数的线性筛法时间复杂度为()。
12.归并排序的基本思想是()。
A. 动态规划B. 分治C. 贪心算法D. 回溯算法13.在快速排序中,选择的主元素(pivot)会影响算法的()。
A. 不影响B. 时间复杂度C. 空间复杂度D. 时间复杂度和空间复杂度14.递归函数在调用自身时,必须满足(),以避免无限递归。
A. 有终止条件。
B. 函数参数递减(或递增)。
C. 函数返回值固定。
D. 以上都对。
15.假设给定链表为:1→3→5→7→nullptr,若调用searchValue(head, 5),函数返回值为()。
2022第五届大学生计算机技能应用大赛(Java科目430道官方题库+答案)1、开发中使用泛型避免使用非泛型,程序的运行时性能会大幅提升。
正确答案: B正确错误2、ArrayList类的底层数据结构是()。
正确答案: A数组结构链表结构哈希表结构红黑树结构3、给定下面的类定义Class Base{Public Void Say(){System.out.println("base");}}Public Class Say Extends Base{Public Static Void Main(string Argv[]){Say S = New Say();S.say();}}下面在类say中使用哪一个方法将会编译并使程序打印出字符串"hello"?( )正确答案: Cpublic int say(){ System.out.println("Hello");}public void say(long l){ System.out.println("Hello");} public void say(){ System.out.println("Hello");}public void say(void){ System.out.println("Hello");}4、System.out.println(‘a’ + 0);语句的输出结果是a0。
( ) 正确答案: B正确错误5、public static void main(String[] args) {Runnable runnable = new Runnable() {@Overridepublic void run() {System.out.print(1);}};Thread thread = new Thread(runnable);thread.run();System.out.print(2);}运行结果为()。
第九届东北地区大学生程序设计竞赛获奖及排名奖项学校队名排名Solved Time 一等奖哈尔滨工业大学哈工大_楼上好强!!!!!!!!!!1101470一等奖大连理工大学Don't Starve281063一等奖哈尔滨工业大学哈工大_吃货381246一等奖吉林大学JLU_A481247一等奖东北大学学妹萌哒哒57811一等奖东北大学大孩纸67905一等奖哈尔滨工程大学三只小熊77936一等奖哈尔滨理工大学哈理工1队87961一等奖东北师范大学东北师大二队971061一等奖东北师范大学矩阵1071103一等奖哈尔滨工业大学哈工大_流星1171163一等奖东北大学队名我忘了126546一等奖哈尔滨工业大学哈工大_我的队友不可能那么可爱136568天津大学取个好名去比赛146603一等奖长春理工大学我认为推倒萝莉是合法的156687一等奖大连理工大学En Taro Tassadar166709一等奖东北林业大学飞龙骑脸176792二等奖东北大学射手与狮子186867二等奖哈尔滨理工大学哈理工3队196900二等奖长春理工大学你为什么打我闺女?206933二等奖吉林大学JLU_K216969二等奖吉林大学JLU_J2261164二等奖东北大学AC真奇妙235384二等奖哈尔滨工业大学哈工大_低空飘过245411二等奖东北林业大学稻草人255446二等奖大连理工大学sword art265478二等奖哈尔滨工业大学哈工大_五月革命275491二等奖哈尔滨工程大学小绿285499二等奖大连理工大学Lingering sound295527二等奖黑龙江科技大学黑科大1队305553二等奖大连理工大学萌神Orz315610二等奖东北大学新军出征325670二等奖内蒙古大学弗斯特布拉德335742二等奖哈尔滨工业大学哈工大_七月345808二等奖大连理工大学楼下似乎想说些什么355813二等奖长春理工大学你为什么打我儿子?365852二等奖东北师范大学暴风雪375951二等奖哈尔滨工程大学梦之继承者385957二等奖大连理工大学Team5395962二等奖东北林业大学指针404259二等奖东北林业大学幸运儿414273二等奖哈尔滨理工大学哈理工2队424274二等奖东北大学听说fb跟a+b更配噢434306二等奖哈尔滨工程大学逆转命运444310二等奖黑龙江大学麦克斯韦454311二等奖哈尔滨商业大学HRBCU_巡夜人464322二等奖哈尔滨理工大学哈理工6队474324二等奖内蒙古师范大学取个队名真费劲484331二等奖哈尔滨理工大学哈理工4队494347三等奖东北林业大学不知道咋AC504351三等奖哈尔滨工程大学我不要学大物!514364三等奖哈尔滨工业大学哈工大_黑猫警长524388三等奖大连理工大学OldBurden534393天津大学英菲尼迪544401三等奖哈尔滨理工大学哈理工5队554401三等奖哈尔滨工程大学合作快车队564406三等奖哈尔滨工业大学哈工大_我们只会中文题574408三等奖哈尔滨工业大学哈工大_哦哟584423三等奖大庆师范学院传奇594426三等奖哈尔滨理工大学哈理工7队604428三等奖大连理工大学求过签到题614438三等奖东北林业大学三个傻吊624440三等奖东北农业大学八月的肖邦634454三等奖长春理工大学你为什么打我丫鬟?644481三等奖吉林工程技术师范学院起跑654501三等奖东北大学极速code664505三等奖东北林业大学小蜜蜂674518三等奖东北师范大学跟着我左手右手一个慢动作684526三等奖东北农业大学也无雨雪,也无晴694535三等奖哈尔滨华德学院队名没起好704544三等奖哈尔滨工程大学三只小猫714550三等奖东北师范大学菜鸟程序猿724596三等奖沈阳航空航天大学pc-2734604三等奖辽宁科技大学新越744607三等奖北华大学飞跃754631三等奖通化师范学院app764640三等奖长春工业大学FIRST BLOOD774650三等奖哈尔滨商业大学HRBCU_克里丝塔784657三等奖辽宁科技大学无名794695三等奖吉林大学JLU_Q804710三等奖长春大学CCU1814769三等奖东北师范大学觉得好就通过呗824866三等奖大连大学大连大学03834956天津大学依然完美843102三等奖北华大学菜刀一队853104三等奖哈尔滨工程大学梦想AC863123三等奖大连理工大学Cappucci Nokia873125三等奖哈尔滨商业大学HUC_码出人生883138三等奖哈尔滨理工大学哈理工9队893140三等奖牡丹江师范学院黑狗903146三等奖哈尔滨工业大学哈工大_帕丁顿熊913149三等奖黑龙江大学战嚎923150三等奖北华大学Excalibur933156三等奖长春工业大学人文信息学院长春小旋风943170三等奖大连理工大学For The Dream953191三等奖佳木斯大学九日王朝963201三等奖东北林业大学纯牛奶973212三等奖沈阳航空航天大学美好时光983236三等奖东北林业大学草稿纸993237三等奖东北师范大学年少梦未了1003258三等奖黑龙江工程学院明日之星1013259三等奖内蒙古工业大学IMUT_飞熊队1023262优胜奖大庆师范学院算无遗策1033274优胜奖长春工业大学撸完代码去撸串1043278优胜奖吉林大学JLU_101053279优胜奖内蒙古科技大学Hello World1063290优胜奖内蒙古科技大学石头剪刀布1073293优胜奖哈尔滨华德学院春天的阳光1083300优胜奖沈阳航空航天大学代码游侠1093323优胜奖大连民族大学iMax1103334优胜奖内蒙古财经大学众神之巅1113335优胜奖东北师范大学摩擦摩擦1123341优胜奖内蒙古大学三只小猪1133356优胜奖东北大学乌鸦小队1143363优胜奖哈尔滨理工大学哈理工8队1153364南阳理工学院东北这么大俺来瞅瞅1163367优胜奖东北大学你们别这样,我们还是孩子1173380优胜奖黑龙江科技大学黑科大3队1183382优胜奖大连民族大学晓月1193391优胜奖辽宁大学144 面试1203401优胜奖哈尔滨工程大学银河算法1213449优胜奖哈尔滨华德学院明天1223450优胜奖黑龙江大学十一月十一1233457优胜奖黑龙江大学两个孙孙一个叉1243479优胜奖北华大学酷乐猫1253503优胜奖长春工业大学人文信息学院没有队名1263512优胜奖大连大学大连大学021273518优胜奖大连大学大连大学011283605优胜奖东北电力大学东电一队1293614优胜奖内蒙古大学迷失在月球1303644优胜奖通化师范学院来包辣条不能断1313646优胜奖内蒙古农业大学职业技术学院内蒙古农大职院2队1323724优胜奖东北师范大学东北师范大学附属幼儿园133252优胜奖内蒙古师范大学阳光女孩134257优胜奖黑龙江大学彩虹135264优胜奖长春理工大学光电信息学院无限天空136265优胜奖辽宁科技大学一起来AC137272优胜奖牡丹江师范学院牡师院三队138274优胜奖哈尔滨学院HRBU_学渣行动组139277优胜奖吉林农业科技学院月亮湖140281优胜奖牡丹江师范学院牡师院二队141282优胜奖内蒙古师范大学获奖名单宣读完毕142284优胜奖通化师范学院人生得意须尽欢143286优胜奖东北农业大学寻找水题的小队144290优胜奖辽宁科技大学吸血鬼战士1452102优胜奖通化师范学院方便面1462107优胜奖内蒙古大学万般皆下属,唯有AC高1472107优胜奖黑龙江科技大学黑科大2队1482113优胜奖吉林师范大学吉师梦之队1492122优胜奖东北师范大学东师_AC旅行鸟1502125优胜奖长春大学CCU21512137优胜奖大连理工大学WA Rush1522138优胜奖长春工业大学复仇ers1532138优胜奖东北电力大学东电二队1542144优胜奖内蒙古工业大学IMUT_龙之队1552153优胜奖吉林工程技术师范学院开战1562166优胜奖沈阳航空航天大学sau学生1572171优胜奖长春师范大学长师一队1582172优胜奖佳木斯大学APCLS1592174优胜奖大连民族大学Blue Sky1602199优胜奖黑河学院勇敢的心1612215优胜奖黑龙江工程学院奋斗1622226优胜奖吉林农业科技学院摩天大楼1632233优胜奖内蒙古农业大学职业技术学院内蒙古农大职院1队1642254优胜奖内蒙古财经大学易1652258优胜奖黑河学院第一1662479优胜奖长春师范大学长师二队1672480最佳女队奖哈尔滨工业大学哈工大_七月。
单选题46、若输入ab,程序运行结果为()。
main(){ static char a[2];scanf("%s",a);printf("%c,%c",a[1],a[2]);}**C**A) a,bB) a,C) b,D) 程序出错47、若有说明: int a[3][4]={0};则下面正确的叙述是()。
**D**A) 只有元素a[0][0]可得到初值0B) 此说明语句不正确C) 数组a中各元素都可得到初值,但其值不一定为0D) 数组a中每个元素均可得到初值048、若有说明:int a[][3]={1,2,3,4,5,6,7};则a数组第一维的大小是()。
**B**A) 2B) 3C) 4D) 无确定值49、设有数组定义: char array [ ]="China"; 则数组 array所占的空间为()。
**C**A) 4个字节B) 5个字节C) 6个字节D) 7个字节50、C语言程序中,当调用函数时()。
**A**A) 实参和虚参各占一个独立的存储单元B) 实参和虚参可以共用存储单元C) 可以由用户指定是否共用存储单元D) 计算机系统自动确定是否共用存储单元51、C语言程序中,若对函数类型未加显式说明,则函数的隐含说明类型为()。
**C**A) voidB) doubleC) intD) char52、C语言程序中必须有的函数是()。
**B**A) #include "stdio.h"B) mainC) printfD) scanf53、C语言规定:简单变量做实参时,它和对应形参之间的数据传递方式是()。
**B**A) 地址传递B) 单向值传递C) 由实参传给形参,再由形参传回给实参D) 由用户指定的传递方式54、当调用函数时,实参是一个数组名,则向函数传送的是()。
**B**A) 数组的长度B) 数组的首地址C) 数组每一个元素的地址D) 数组每个元素中的值55、对于void类型函数,调用时不可作为()。
黑龙江科技大学C语言程序设计冲刺卷考试时间:【120分钟】总分:【150分】得分评卷人一、单项选择题(共20题,每题2分,共计40分)()1、下列4种不同数制表示的数中,数值最小的一个是________。
A、八进制数52B、十进制数44C、十六进制数2BD、二进制数101001()2、关于数据类型存储大小从小到大正确的是________。
A、sizeof(char)<sizeof(short int)<sizeof(int)<sizeof(float)B、sizeof(char)<sizeof(short int)<sizeof(int)<sizeof(double)C、sizeof(char)<sizeof(int)<sizeof(long int)<sizeof(float)D、sizeof(char)<sizeof(unsigned int)<sizeof(long int)<sizeof(double)()3、下列语句中,不正确的一个是______。
A、float e=1.1f;B、char f=-1.1f;C、double g=1.1f;D、byte h=1;()4、当从键盘上输入字符"12134211"下面程序的 输出结果是________。
main( ){char s;int v1=0,v2=0,v3=0,v4=0,k;for(k=0;k<=7;k++){scanf("%c",&s);switch(s){default: v4++;case '1': v1++;case '3': v3++;case '2': v2++;}}printf("v1=%d,v2=%d,v3=%d,v4=%d\n",v1,v2,v3,v4);}A、v1=4,v2=2,v3=1,v4=1B、v1=4,v2=9,v3=3,v4=1C、v1=5,v2=8,v3=6,v4=1D、v1=8,v2=8,v3=8,v4=8()5、有以下程序#include <stdio.h>main(){int x=1,y=0,a=0,b=0;switch(x){case 1: switch(y){case 0: a++;break;case 1: b++;break;}case 2: a++;b++;break;case 3: a++;b++;}printf("a=%d,b=%d\n",a,b);}程序的运行结果是________。
A. 最⼩公倍数B. 最⼤公约数C. 数字x 能够整除y 的最⼩数D. 数字x 与数字y 的所有公约数第 2 题 下列程序中实现的是( )A. 实现了求x,y 的最⼩公约数B. 实现了求x,y 的最⼤公约数C. 实现了求x,y 的最⼩公倍数B.def chenadai (x , y ): while y :x , y = y , x % y return x 1234def chenadai (x , y ):return x * y // (x ,y 的最大公约数)12def gcd (a ,b ): if b == 0: return areturn gcd (b , a % b )1234C.D. 4 题 下列程序是⼆分法的程序,横线处应该填上( )。
A. B. C.def gcd (a , b ): if a < b :a ,b = b , a while b != 0: a ,b = b ,a %b return b123456def gcd (a ,b ): if b == 0:return areturn gcd (a , a % b )1234def gcd (a ,b ): if b == 0: return areturn gcd (b , b % a )1234def binary_search (arr , target ): left = 0right = len (arr ) - 1 while left <= right :mid = (left + right ) // 2 _________________________ return -11234567if arr [mid ] == target : return midelif arr [mid ] > target : right = mid - 11234if arr [mid ] == target : return midelif arr [mid ] > target : right = mid else :left = mid123456D. 5 题 下⾯折半查找程序的时间复杂度为( )A. B. C. D.第 6 题 下列程序中,使⽤了埃⽒筛法,横线处应该填写的是()A. for p in range(2, n ** 0.5 + 1):B. for p in range(2, int(n ** 0.5) + 1):C. for p in range(2, int(n ** 0.5) + 0.5):if arr [mid ] == target : return midelif arr [mid ] > target : right = mid - 1 else :left = mid + 1123456if arr [mid ] == target : return mid else :left = mid + 11234def binary_search (arr , x ): low = 0high = len (arr ) - 1 while low <= high :mid = (low + high ) // 2 if arr [mid ] == x : return midelif arr [mid ] > x : high = mid - 1 else :low = mid + 1 return -1123456789101112def aishishai (n ): if n < 2:return []prime = [True ] * (n + 1) prime [0] = prime [1] = False——————————————————————————————————if prime [p ]:for i in range (p * p , n + 1, p ): prime [i ] = Falsereturn [p for p in range (n + 1) if prime [p ]]12345678910A. 1,2,3,13,23B. 2,7,11,23C. 2:3,11:1,23:1D. 2,3,13,23第 9 题 下⾯关于循环链表的说法正确的是( )。
第五届省赛1.一个串的子串是指该串的一个连续的局部。
如果不要求连续,则可称为它的子序列。
比如对串: "abcdefg" 而言,"ab","abd","bdef" 等都是它的子序列。
特别地,一个串本身,以及空串也是它的子序列。
对两个串而言,可以有许多的共同的子序列,我们关心的是:它们所共同拥有的长度最大的子序列是多长。
以下代码实现了这个问题的求解。
请填写划线部分缺失的代码。
注意:只填写划线部分缺少的内容,不要填写任何多余的符号或注释、说明等。
例如,不要填写已经给出的小括号。
inline max(int a, int b){return a>b?a:b;}int f(char* x, char* y){if(strlen(x)==0) return 0;if(strlen(y)==0) return 0;if(*x == *y) return f(x+1, y+1) + 1;return max( ______________________ );//处理字符串}int main(){printf("%d\n", f("ac","abcd")); //2printf("%d\n", f("acebbcde1133","xya33bc11de")); //5return 0;}f(x+1,y),f(x,y+1)2.历史上有许多计算圆周率pai的公式,其中,格雷戈里和莱布尼茨发现了下面的公式:pai = 4*(1-1/3+1/5-1/7 ....)参见【图1.png】这个公式简单而优美,但美中不足,它收敛的太慢了。
如果我们四舍五入保留它的两位小数,那么:累积了1项和是:4.00累积了2项和是:2.67累积了3项和是:3.47。
第五届黑龙江大学生程序竞赛题目1001There is a football game between teamX and teamY, we assume the position of the center of football ground is (0, 0),the position of the teamY's goal is(100,0),the position of the teamX's goal is(-100,0).Now xiaoA in teamX wants to pass the football to his teammate xiaoB, was xiaoB offside(越位)?InputThe first line of input contains a positive integer N <= 10, the number of test cases.For each test case there is one line contains 24 number,the first and second number indicate the position of xiaoA, the third and forth number indicate the opsition of xiaoB, and the remaining numbers indicate the poistions of the team members in teamY.OutputIf xiaoB is offside output "Oh, My god!", else output "Come on!"Sample Input1-99 0 99 0 1 0 2 0 3 0 4 0 5 0 6 0 7 0 8 0 9 0 10 0Sample OutputOh, My god!HintIf xiaoA passes the football to xiaoB, and there is no members of teamY in front of xiaoB,then xiaoB is offside1002xiaoA is a beautiful girl, and she has so many skirts that she won't wear a skirt a second time before the skirt is washed.Now xiaoA wants to go shopping,how many skirts she can choose to wear.In order to distinguish these skirts,she gives out every skirt with a unique name.The first line of input contains a positive integer T (T <= 100), the number of test cases.Each test case contains two integers N and M (1<=N,M<=100) in the first line.N is the number of skirts.M is the number of operations.Then N lines follow.Every line contains a word and the word is not longer than 10.Then M lines follow.Each line contains a character 'D' or 'W' and the name of a skirt.'D' indicates that xiaoA has wore the skirt. 'W' indicates that xiaoA has washed the skirt.OutputAfter the M operations, you need to output that how many skirts can be chosen by xiaoA to wear.Sample Input15 5SkirtASkirtBSkirtCSkirtDSkirtED SkirtAD SkirtBD SkirtCD SkirtDW SkirtASample Output21003XiaoA has N friends , now he would like to contact his friend N , but unfortunately , he lost his mobile phone, and he can just come up with friend 1 's phone number. Can you tell us whether he can build contact with his friend N.The first line of input contains a positive integer T <= 100, the number of test cases. For each case , there is an integer N (1<=N<=100) in the first line , means xiaoA has N friends , then follows N lines , in the ith line , there is an integer M first, means xiaoA’s friend i can contact with M xiaoA’s friends , then follows M integers kij , means friend i of xiaoA can contact with xiaoA’s friend kij (1<=i<=N,1<=j<=M,1<=kij<=N) .OutputFor each test case , print one line "yes" if xiaoA can contact with friend N , or "no" instead.sample input251 21 31 41 54 1 2 3 453 2 3 43 1 3 43 1 2 43 1 2 34 1 2 3 4sample outputyesno1004Happy New Term!As having become a junior, xiaoA recognizes that there is not much time for her to AC problems, because there are some other things for her to do, which makes her nearly mad.What's more, her boss tells her that for some sets of duties, she must choose at least one job to do, but for some sets of things, she can only choose at most one to do, which is meaningless to the boss. And for others,she can do of her will. We just define the things that she can choose as "jobs". A job takes time , and gives xiaoA some points of happiness (which means that she is always willing to do the jobs).So can you choose the best sets of them to give her the maximum points of happiness and also to be a good junior(which means that she should follow the boss's advice)?InputThere are several test cases, each test case begins with two integers n and T (0<=n,T<=100) , n sets of jobs for you to choose and T minutes for her to do them. Follows are n sets of description, each of which starts with two integers m and s (0<m<=100), there are m jobs in this set , and the set type is s, (0 stands for the sets that should choose at least 1 job to do, 1 for the sets that should choose at most 1 , and 2 for the one you can choose freely).then m pairs of integers ci,gi follows(0<=ci,gi<=100), means the ith job cost ci minutes to finish and gi points of happiness can be gained by finishing it. One job can be done only once.OutputOne line for each test case contains the maximum points of happiness we can choose from all jobs .if she can’t finish what her boss want, just output -1 .Sample Input3 32 12 53 82 01 02 13 24 32 11 13 42 12 53 82 01 12 83 24 42 11 11 11 02 15 32 01 02 12 02 21 12 03 22 12 11 52 83 23 84 95 10Sample Output513-1-11005Little A is a playing boy, but you are a student. So when every day Little A arrives at home, he will accomplish his homework as soon as possible, and then go to play with his friends. Every day his teacher will let him accomplish much homework but the homework has a problem that if he hasn’t accomplished the ith homework he can’t start to write the jth homework. Little A is so clever that he can write much homework at the same time. Now he wants to know the least time he need. You are a clever boy, so you can help him to solve that, right?InputThere are several test cases. For each test case, the first line contains two integers N (1<=N<100), M (1<=M<=10000), represent there are N homework and M relations. Then a line contains N numbers, the ith number ti represents the ith homework need ti(1<=ti<=100) seconds . Then M lines follow, each line contains two numbers x, y, means that the xth homework must be finished before the yth homework start.OutputFor each test case, if the homework can be finished, print the least time (in seco nds) in a line .Or you will output “What a cup!”Sample Input5 41 2 3 4 51 23 42 54 5Sample Output121006Today XiaoA’s Math teacher gives him a problem. The problem is that he has N (1<=N<=100000) operations, which he will write a number on the blackboard or ask you how many numbers are between x and y (1<=x,y<=1000000000) on the blackboard. XiaoA don’t know how to solve it ,but he has a very clever friend ,you , so he turns to you. You can help him, can’t you?InputThere are several test cases , for each test case , the first line contains only a number N , represent there are N operations. Then N lines follow , each line contains two or three parts .The first part is a string , if the string is “Insert” then a number p(1<=p<=1000000000)follows ,represent the teacher write a number p on the blackboard, if the string is “Question” then following two numbersx,y(1<=x,y<=1000000000) , represent that the teacher ask you the number of numbers on the blackboard between x and y(including x and y).OutputFor each question you should output a line contains a number for the “question”.Sample Input10Insert 50Question 1 100Insert 2Question 2 3Insert 1000Question 50 100Insert 20Question 1 100Insert 5000Question 1000 5000Sample Output111321007DescriptionConsider the following programming language. This language contains only two types of statements: simple statements and compound statements. The simple statement is in the form “write (literal)”, where “write” is a key word indicating that the content of the literal should be written to the standard output. The content of literals is surrounded by a pair of double quotes. The compound statement is in the form “if (<expression>) <statement>” or “if (<expression>) <statement> else <statement>”. Here “if” and “else” are key words and “expression” can be either “1” or “0” indicating “true” or “false”. Statement can be eithercompound or simple, which means compound statements can be nested. Note that each “else” should match the nearest “if”.InputThe input has multiple test cases. Every test case is exactly a statement. Every test case is ended with an empty line and there will be no empty lines within a statement. Please pay attention that empty lines separate the statements and adjacent statements are independent of each other.OutputFor all the contents of literals that should be written to the standard output, print them on a single line, without the double quotes. The contents of literals will contain only lower case letters.Sample Inputwrite(“q”)if(0) write(“x”) else write(“y”)if(1) if(0) write(“x”) else write(“y”)if(0) if(0) write(“x”) else write(“y”)Sample OutputqyyHint:The 4th test case has no output.1008Little A has many cubes. He number these cubes from 1 to n. then, named them as their number’s three cubed, for example, if one cube’s number is 3, then its name is 27. Now, Little A wants to make a super m cubic lineup, and how many cubes does he need. The super m cubic lineup means pick out m cubes from n, and the name of any one in m cubes and the name of any cube’s in m-1 have the same numbers.InputThere are several test cases.Each case has one positive integer m(1<=m<=15),indicate that Little A wants to make a super m cubic lineup.OutputOutput one line contain one integer n for each case, means Little A should have n cubes at least to form the super m cubic lineup.Sample Input12Sample Output18HINT:To make a super 1 cubic lineup, only need one cube. To make a super 2 cubic lineup, at least need 8 cubes. As these 8 cubes’ name is (1, 8, 27, 64, 125, 216, 343, 512), you can pick out the fifth cube with name 125 and the eighth cube with name 512. Both name have same numbers:1, 2, 5.。