Starting from:
$30

$24

A: Find Algorithms Solution

题目描述







Give you an algorithm set and an article, please answer whether algorithms in the given set appears in the article.

输入







The first line of input is the number of test cases T (1 <= T <= 100)




For each test case, the first line will be an integer n (1 <= n <= 10). The next n lines describe the given algorithm set. Each line will contain a string.




Then there will be an integer m (1 <= m <= 1000). Then there will be m words (strings) describe the article.




These strings are separated by space.




We guarantee the given string only contains lowercase and uppercase English letters. And the length of each string is less than 100.







输出







For each article, if one of the given algorithms appears in the article, print “Appeared” (without quotes).




Otherwise print “Not appeared” (without quotes).










样例输入










2




3




DynamicProgramming




SweepLine




dijkstra




8




We can solve this problem by sweepline algorithm




3




DynamicProgramming




SweepLine




dijkstra




9




Dijkstra algorithm can be used to solve SSSP problem

样例输出










Appeared




Appeared




问题 B: Tower of Hanoi







题目描述







Tower of Hanoi is one of the most famous puzzles in the world. There are three different rods labeled A, B and C. The puzzle starts with the disks in ascending order of size on the A rod (The smallest at the top). You have the following rules:




Only one disk can be moved at a time.



Each move consists of taking the upper disk from one of the rods and placing it on top of another rod.



No disk can be placed on top of a smaller disk.



Since the problem is too popular that you must know how to solve it, we add several constrains to this problem:




You cannot move disk between the A rod and the C rod directly.



You need to move n disks from the A rod to the C rod.



Please write a program to print the minimum number of moves you need to do. Since the result is too large, please print the answer modular 1000000007.




If you do not know the modular operation, here is the link:




https://en.wikipedia.org/wiki/Modular_arithmetic










输入







The first line of input is the number of test cases T (1 <= T <= 100)




For each test case, the first line will be an integer n (1 <= n <= 1000). Means there are n disks on the A rod initially.







输出



For each test case, print the minimum number of moves you need to do when there are n disks on the A rod initially.







样例输入










2




1




2




样例输出










2




8




问题 C: Chess Game







题目描述







Give you a chessboard of n row and m columns. Alice and Bob want to play a game with the following rules:




Alice moves first. And they take turns to move. Alice uses black piece and Bob uses white piece.



For each move, the player must chose an empty grid (x0, y0) and occupy all grids (x, y) which satisfy x =



x0 and y = y0.




The player who occupies the grid (1, 1) will lose.



Alice and Bob are both clever enough. Please write a program to predict the winner of the game.










输入







The first line of input is the number of test cases T (1 <= T <= 100)




For each test case, the first line will be two integers n, m (1 <= n, m <= 1000).










输出



For each test case, print the name of the winner. (Alice / Bob)










样例输入










2




1 1




1 2




样例输出










Bob




Alice







问题 D: 3-D Print







题目描述







Please write a program to print a 3D cuboid with length a, width b and height c. You can the details in the sample input and output.







输入







The first line of input is the number of test cases T (1 <= T <= 100)




For each test case, the first line will be three integers a, b and c (1 <= a, b, c <= 30).










输出







For each test case, print the cuboid as the sample output.










样例输入



2

1 1 1




6 2 4




样例输出










..+-+




././|




+-+.+




|.|/.




+-+..




....+-+-+-+-+-+-+




.../././././././|




..+-+-+-+-+-+-+.+




./././././././|/|




+-+-+-+-+-+-+.+.+




|.|.|.|.|.|.|/|/|




+-+-+-+-+-+-+.+.+




|.|.|.|.|.|.|/|/|




+-+-+-+-+-+-+.+.+




|.|.|.|.|.|.|/|/.




+-+-+-+-+-+-+.+..




|.|.|.|.|.|.|/...




+-+-+-+-+-+-+....







问题 E: Maximum difference







题目描述







Give you n integers a1, a2, … , an. Please find two integers ai and aj (i < j), such that ai – aj is maximum.










输入







The first line of input is the number of test cases T (1 <= T <= 10)




For each test case, the first line will be an integer n (2 <= n <= 200000). Then there are n integers. 0<= ai <= 100000.
输出







For each test case, print the maximum difference.










样例输入










1




5




1 2 3 4 5




样例输出










-1










问题 F: Beautiful pairs







题目描述







A pair of English letters (a, b) is considered beautiful iff one of them is uppercase, the other is lowercase and both of them are consonants. (English letters except a, e, i, o, u, w and y). Now give you a string which is consists of lowercase English letters. Now you can change several letters from lowercase to uppercase. Please write a program to calculate the maximum number of beautiful pairs formed by adjacent letters.




Note: If you change x to X, then all x in the string will become X.




For example, if we have string strength, we can change it to StRenGtH. In this case, (S,t), (t,R),(n,G),(G,t) and (t,H) are beautiful. So the result is 5.







输入







The first line of input is the number of test cases T (1 <= T <= 10)




For each test case, there will be a string consists of lowercase English letters. The length of the string does not exists 10000.

输出







For each test case, print the maximum number of adjacent beautiful pairs you can find.










样例输入










2




strength




consonants




样例输出










5




2

问题 G: Box







题目描述







As we know boxes are in a shape of rectangular parallelepipeds. Now we have a cardboard of size n * m.




Please write a program to check whether it can form a box of size a * b * c.




The following sample is one possible way for the first sample.










输入
The first line of input is the number of test cases T (1 <= T <= 100)




For each test case, the first line will be three integers a, b and c (1 <= a, b, c <= 100000000). The second line are two integers n and m. ( 1 <= n, m <= 100000000)




输出







For each test case, print “Yes” (without quotes) if you can form the box of size a * b * c. Otherwise print “No”.










样例输入










1




1 2 3




6 5




样例输出









More products