To evaluate the performance of our first year CS majored students, we consider their grades of three courses only: C – C Programming Language, M – Mathematics (Calculus or Linear Algebra), and E – English. At the mean time, we encourage students by emphasizing on their best ranks — that is, among the four ranks with respect to the three courses and the average grade, we print the best rank for each student. For example, 继续阅读

This time, you are supposed to find A*B where A and B are two polynomials. Input Specification: Each input file contains one test case. Each case occupies 2 lines, and each line contains the information of a polynomial: K N1 aN1 N2 aN2 … NK aNK, where K is the number of nonzero terms in the polynomial, Ni and aNi (i=1, 2, …, K) are the exponents and coefficients, respectively. It is given that 继续阅读

The highest building in our city has only one elevator. A request list is made up with N positive numbers. The numbers denote at which floors the elevator will stop, in specified order. It costs 6 seconds to move the elevator up one floor, and 4 seconds to move down one floor. The elevator will stay for 5 seconds at each stop. For a given request list, you are to compute the total time spent 继续阅读

题目给出K个整数。一个连续的片段是指 N[i], N[i+1], …, N[j](1≤i≤j≤K),最大片段是指拥有最大片段和的片段。比如给出数据{ -2, 11, -4, 13, -5, -2 },它的最大片段是 继续阅读

As an emergency rescue team leader of a city, you are given a special map of your country. The map shows several scattered cities connected by some roads. Amount of rescue teams in each city and the length of each road between any pair of cities are marked on the map. When there is an emergency call to you from some other city, your job is to lead your men to the place as quickly 继续阅读

并查集,即不相交集合,用森林表示。主要操作有初始化、查询、合并。 初始化 每个元素都建立一个只含自己的集合,每个元素都是自己所在集合的代表,把每个元素的父 继续阅读

平衡树(自平衡二叉排序树)前提是一棵二叉排序树。 如果把结点 1、2、3、4、5 依次插入到二叉排序树,得到的结果: 很明显这棵树已经退化为链表,效率降低,需 继续阅读

This time, you are supposed to find A+B where A and B are two polynomials. Input Each input file contains one test case. Each case occupies 2 lines, and each line contains the information of a polynomial: K N1 aN1 N2 aN2 … NK aNK, where K is the number of nonzero terms in the polynomial, Ni and aNi (i=1, 2, …, K) are the exponents and coefficients, respectively. It is given that 1 继续阅读

在n×n的方阵里填入1,2,3,…,n×n,要求填成蛇形。例如,n=4时,方阵为 10 11 12 1 9 16 13 2 8 15 14 3 7 6 5 4 方阵中空格只为便于判断规律,不必严格输 继续阅读

输入一个字符串,判断它是否为回文串或者镜像串。输入字符保证不含有数字0。 回文串:反转后和原串相同,如abba和madam。 镜像串:串水平镜像后和原串相 继续阅读

PAGE 1 / 1