【思维+暴力】Block Towers

 

Students in a class are making towers of blocks. Each student makes a (non-zero) tower by stacking pieces lengthwise on top of each other. n of the students use pieces made of two blocks and m of the students use pieces made of three blocks.

The students don’t want to use too many blocks, but they also want to be unique, so no two students’ towers may contain the same number of blocks. Find the minimum height necessary for the tallest of the students’ towers. 继续阅读【思维+暴力】Block Towers

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