ACM黑龙江大赛

Problem A:Reverse
Given an array of integers,your job is to print it in the reverse order.
For example:Given an array of 1,2,3,4,5you should output 5,4,3,2,1.
Input
Input contains multiple test cases.The first line is an integer T,the number of test cases.The first line of each test case is an integer N,the number of elements in the array.Then a line with N integers followd.
Output
For each test case,print the reversed order of the input array.
Sample Input
1
5
1 2 3 4 5
Sample Output
5 4 3 2 1


问题 A : 倒转
 
   给你一个整形类型的数组,你所要做的是打印出它的逆序。

   例如:给你一个数组的序列是1,2,3,4,5,你应该输出5,4,3,2,1。
输入
   输入包括多个测试用例。第一行是整形变量T,它是测试用例的个数。每个测试用例的第一行为整形变量N,它是数组的大小。下面的一行是N个整形变量。
输出
    对于每个测试用例,打印出输入数组的逆序。
输入样例
1
5
1 2 3 4 5
输出样例
5 4 3 2 1


Problem C:Euler Graph
Euler graph is a graph that you can start from one vertex X and go through all the edges only once and go back to vertex X,your task is to judge whether a given graph is a Euler graph or not.
A graph will be given like this:
Given n vertexes identified from 1 to n,and a set of edges described as i,j which means that there is a edge from vertex i to vertex j.Edges are directional.
Input
Input contains several test cases.First line of the input file is a integer t(1<=t<=100) presents the number of test cases.Each test cases contains two parts.Part one contains two integer n and m.n is the number of vertexes and m is the number of edges.Part two contains m lines with two integers(i and j)1<=i,j<=100.
Output
For each test case,print yes if the graph is a Euler graph and no if not.
Sample Input
2
5 5
1 2
2 3
3 4
4 5
5 1
4 3
1 2
2 3
3 4
Sample Output
yes
no


问题 C: 欧拉图

   欧拉图是一个你可以从节点X出发,遍历所有边仅存在一条回路返回到节点X
。你的任务是判断一个给定的图是否为欧拉图。
一个给定的图可能是像下面这样:
给n个节点表示为从1到n,并且一系列的边用i,j来描绘,它的意思是存在一条边从节点i到节点j。这些边都是直接相连的。

输入
输入包括一些测试用例。第一行输入一个整形变量t(1<=t<=100),它代表的是测试用例的数目。每个测试用例包括两个部分,第一部分包含两个整形变量n,m。n代表节点数,m代表边数。第二部分包含m行,每行输入两个整形变量(i 和 j)1<=i,j<=100。

输出
对于每个测试用例,如果是欧拉图打印是,不是的话打印不是。
输入样例
2
5 5
1 2
2 3
3 4
4 5
5 1
4 3
1 2
2 3
3 4
输出样例




Problem D:Exchange Apples
There are N(2<=n<=100000)students standing in q lines,the distance between adjacent students is 1.A student send one apple to the adjacent student takes 1 unit of work.Each student may have extra apples or he may want some apples.
Give you a sequence of integers,integer Xi at the position of i means that i’th student has Xi extra apples,if Xi is negative,it means that he want Xi apples.
Your job is to find the minimum overall work of all the students to make that none student have extra apples nor student want apples.You may assume that the sum of all Xi(1<=i<=N) is 0.
Input
Input contains multiple test cases.The first line is an integer,the number of cases.Each case begins with an integer N,then N integer follows.
Output
For each case print the minimum amount of work needed to fulfill the problem.
Sample Input
2
5
6 -4 1 -4 1
6
-6 -7 -8 8 9 4
Sample Output
12
57

问题 D: 交换苹果
有N个学生站成q列,邻近学生的距离是1。学生A给邻近的学生一个苹果,他用一个单位的工作量。每一个学生可能有额外的苹果,或者他需要一些苹果。
给你一系列整形变量,整形Xi意思是第i个学生有Xi个额外的苹果,如果Xi为负数,它的意思是这个学生需要Xi个苹果。
你所要做的是,用最小的工作量使得所有的学生都没有额外的苹果,而且没有学生需要苹果。你可以认为Xi(1<=i<=N)的总和为0。
输入
输入包含多个测试用例。第一行是一个整形变量,它是测试用例的数目。每一个测试用例以N开头,后面跟随N个整形变量。
输出
对于每个测试用例,打印出最小工作量
输入样例
2
5
6 -4 1 -4 1
6
-6 -7 -8 8 9 4
输出样例
12
57

Problem G:Max
Give you an expression,you can add some parenthesis to maximize the result.Example as following:
1 + 2 * 3
Its result is 7 in the example.But you can add a parenthesis like(1 + 2) * 3,then the result will be 9,and so it is the maximization of the example.Your job is to find the maximization of an expression.To simplify this problem,you can assume that expression contains only operator “+”and “*”,but please note that integers may be negative.
Input
Input contains multiple test cases.Each case begin with an integer N(2<=N<=100),the number of integers of an expression,then goes the expression.Integers and operators are separated with a single white space.
Output
For each case print a single line with the naximized value of the expression.
Sample Input
4
1 + 2 * 3 + -1
Sample Output
8

问题 G: 求最大值
给你一个表达式,你可以增加括号来使结果最大化。如下面的例子:
1 + 2 * 3
它的结果是7。但是你可以增加括号像这样(1 + 2)*3,然后结果为9,这样就是将结果最大化。你所要做的是找到一个表达式的最大化。为了使问题简单一些,你可以仅包含乘号和加号,但是提醒你一下,整形变量可能包含负数。
输入
输入包含多个测试用例。每个测试用例以一个整形变量N开头,它代表表达式的整形变量的个数,后面跟着表达式的值。整形变量和操作符一个空格隔开。
输出
对于每个测试用例,打印出表达式的最大化的值。
输入样例
4
1 + 2 * 3 + -1
输出样例
8

Problem I: Adventure
Once an explorer went on an adventure,but he was stopped by a door that he could not break into.Fortunately he found a table with N*M grids(1<=N,M<=200).Each grid contains a pillar.There were N+M buttons aside,corresponding to the 1th,2,…Nth row and 1th,2,…Mth column in the table.He found that if a buttoned was pressed,the height of pillars in the corresponding row or column would decrease 1.The height of pillars with height 0 would no longer decrease.If the height of all pillars becomes 0,the door would open.Because of risk the explorer wants to open the door as early as possible,that is what is the minimum times he needed to press buttons.
Input
Input contains multiple test cases.First line is an integer T,the number of test cases.The first line of each case contains two integer N,M.Then N lines follow each with M integers.The height of all pillar won’t larger than 10000.
Output
For each test case print a integer,the minimum times the explorer need to press buttons.
Sample Input
2
2 2
1 2
1 1
4 1
1
2
3
4
Sample Output
3
4


问题 I: 探险
曾经有一个探险家去探险,但是他被一个不可打开的门拦住了去路。幸运的是他发现了一个表,表上面有N*M个格。每个格包含一个柱子。这里有 N+M个按钮在旁边,相应的标记为1th,2,...Nth行和1th,2,...Mth列。他发现如果一个按钮被按下,柱子相应的高和宽都减去1。如果所有的柱子的高度变为0,那么这个门将打开。由于情况紧急,探险家必须尽快打开这扇门,这就意味着最短的时间来按按钮。
输入
输入包含多个测试用例。第一行包含一个整形变量 T,它是测试用例的个数。第一行每个测试用例包含两个整形变量N,M.然后N行跟随M个整形变量。柱子的高度不可以大过10000.
输出
对于每个测试用例,打印出探险家需要按的按钮的最小次数。
输入样例
2
2 2
1 2
1 1
4 1
1
2
3
4
输出样例
3
4
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值