## 【思维】Marjar Cola

Marjar Cola is on sale now! In order to attract more customers, Edward, the boss of Marjar Company, decides to launch a promotion: If a customer returns x empty cola bottles or y cola bottle caps to the company, he can get a full bottle of Marjar Cola for free!

Now, Alice has a empty cola bottles and b cola bottle caps, and she wants to drink as many bottles of cola as possible. Do you know how many full bottles of Marjar Cola she can drink?

Note that a bottle of cola consists of one cola bottle and one bottle cap.

Input
There are multiple test cases. The first line of input contains an integer T (1 ≤ T ≤ 100), indicating the number of test cases. For each test case:

The first and only line contains four integers x, y, a, b (1 ≤ x, y, a, b ≤ 100). Their meanings are described above.

Output
For each test case, print one line containing one integer, indicating the number of bottles of cola Alice can drink. If Alice can drink an infinite number of bottles of cola, print “INF” (without the quotes) instead.

Sample Input
2
1 3 1 1
4 3 6 4
Sample Output
INF
4
Hint
For the second test case, Alice has 6 empty bottles and 4 bottle caps in hand. She can return 4 bottles and 3 caps to the company to get 2 full bottles of cola. Then she will have 4 empty bottles and 3 caps in hand. She can return them to the company again and get another 2 full bottles of cola. This time she has 2 bottles and 2 caps in hand, but they are not enough to make the exchange. So the answer is 4.

## 【STL/思维】King of Karaoke

It’s Karaoke time! DreamGrid is performing the song Powder Snow in the game King of Karaoke. The song performed by DreamGrid can be considered as an integer sequence , and the standard version of the song can be considered as another integer sequence . The score is the number of integers satisfying and .

As a good tuner, DreamGrid can choose an integer (can be positive, 0, or negative) as his tune and add to every element in . Can you help him maximize his score by choosing a proper tune?

Input
There are multiple test cases. The first line of the input contains an integer (about 100), indicating the number of test cases. For each test case:

The first line contains one integer (), indicating the length of the sequences and .

The second line contains integers (), indicating the song performed by DreamGrid.

The third line contains integers (), indicating the standard version of the song.

It’s guaranteed that at most 5 test cases have .

Output
For each test case output one line containing one integer, indicating the maximum possible score. 继续阅读【STL/思维】King of Karaoke

## 【概率期望】Island of Survival

You are in a reality show, and the show is way too real that they threw into an island. Only two kinds of animals are in the island, the tigers and the deer. Though unfortunate but the truth is that, each day exactly two animals meet each other. So, the outcomes are one of the following

a)If you and a tiger meet, the tiger will surely kill you.
b)If a tiger and a deer meet, the tiger will eat the deer.
c)If two deer meet, nothing happens.
d)If you meet a deer, you may or may not kill the deer (depends on you).
e)If two tigers meet, they will fight each other till death. So, both will be killed.

If in some day you are sure that you will not be killed, you leave the island immediately and thus win the reality show. And you can assume that two animals in each day are chosen uniformly at random from the set of living creatures in the island (including you).

Now you want to find the expected probability of you winning the game. Since in outcome (d), you can make your own decision, you want to maximize the probability. 继续阅读【概率期望】Island of Survival

## Regular Bracket Sequence（思维）

A string is called bracket sequence if it does not contain any characters other than “(” and “)”. A bracket sequence is called regular if it it is possible to obtain correct arithmetic expression by inserting characters “+” and “1” into this sequence. For example, “”, “(())” and “()()” are regular bracket sequences; “))” and “)((” are bracket sequences (but not regular ones), and “(a)” and “(1)+(1)” are not bracket sequences at all.
You have a number of strings; each string is a bracket sequence of length 2
. So, overall you have 𝑐𝑛𝑡1 strings “((“, 𝑐𝑛𝑡2 strings “()”, 𝑐𝑛𝑡3 strings “)(” and 𝑐𝑛𝑡4 strings “))”. You want to write all these strings in some order, one after another; after that, you will get a long bracket sequence of length 2(𝑐𝑛𝑡1+𝑐𝑛𝑡2+𝑐𝑛𝑡3+𝑐𝑛𝑡4)
. You wonder: is it possible to choose some order of the strings you have such that you will get a regular bracket sequence? Note that you may not remove any characters or strings, and you may not add anything either. 继续阅读Regular Bracket Sequence（思维）

## 【数学】A Cubic number and A Cubic Number

A cubic number is the result of using a whole number in a multiplication three times. For example, 3×3×3=27so

$27$

is a cubic number. The first few cubic numbers are 1,8,27,64 and 125. Given an prime number p. Check that if

$p$

is a difference of two cubic numbers.

InputThe first of input contains an integer T (1T100) which is the total number of test cases.
For each test case, a line contains a prime number p (2p10^12).OutputFor each test case, output ‘YES’ if given p

$p$

is a difference of two cubic numbers, or ‘NO’ if not. 继续阅读【数学】A Cubic number and A Cubic Number