【思维】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.

继续阅读【思维】Marjar Cola

【思维题】 Disturbed People

思维题: 题目链接
思路:

会打扰别人的灯满足条件:

1.前一个灯是灭的。

2.前面的第二个灯和现在的灯是开着的。

arr.get(i-1).equals(0)&&arr.get(i).equals(1)&&(!arr.get(i-2).equals(0)))

注意:

如果满足了上述条件,需要把这个灯关掉再进行以后的判断

import java.math.BigInteger;
import java.util.*;
import java.lang.*;
public class Main {
  
  public static void main(String[] args) {
    Scanner cin=new Scanner(System.in);
    int n=cin.nextInt();
    List<Integer> arr=new ArrayList<Integer>();
    for(int i=0;i<n;i++) {
      arr.add(cin.nextInt());
    }
    int ans=0;
    for(int i=2;i<n;i++) {
      if(arr.get(i-1).equals(0)&&arr.get(i).equals(1)&&(!arr.get(i-2).equals(0))){
          arr.set(i, 0);
          ans++;
        }
    }
  System.out.println(ans);
  }	
}

 

 

codeforces-1037D Berland Fair

题目链接:点我点我w~

XXI Berland Annual Fair is coming really soon! Traditionally fair consists of n booths, arranged in a circle. The booths are numbered through n clockwise with n being adjacent to 1. The i-th booths sells some candies for the price of ai burles per item. Each booth has an unlimited supply of candies. 继续阅读codeforces-1037D Berland Fair