tags: Algorithm Blue Bridge Cup Eleventh
Simple simulation
To the right, down, to the right
package algorithm;
import java.util.Scanner;
public class Look for20 {
static int N = 100000 * 4 + 5;
static int M = 1000 + 5;
static int mod = 1000000009;
static Scanner cin = new Scanner(System.in);
static int ans = 0, n, m;
static char c[][] = new char[M][M];
public static void main(String[] args) {
int n1 =0;
while(cin.hasNext()) {
String s = cin.next();
if ("end".equals(s))
break;
m = s.length();
c[n++] = s.toCharArray();
}
for(int i = 0; i < n; i++){
for(int j = 0; j < m; j++){
if (c[i][j]=='2')
check(i,j);
}
}
System.out.println(ans);
}
private static void check(int i, int j) {
if(i + 3 < n)
if(c[i+1][j] == '0' && c[i+2][j] == '2' && c[i+3][j] == '0')
++ans;
if(j + 3 < m)
if(c[i][j+1] == '0' && c[i][j+2] == '2' && c[i][j+3] == '0')
++ans;
if(i + 3 < n && j + 3 < n)
if(c[i+1][j+1] == '0' && c[i+2][j+2] == '2' && c[i+3][j+3] == '0')
++ans;
}
}
1. Title: Shopping list Xiao Ming just got a job. The boss is very nice, but the boss's wife loves shopping. When the boss is busy, he often asks Xiao Ming to help him go shopping on his behalf. Xiao ...
1. Number of briquettes There is a pile of briquettes, piled into a triangular pyramid. specific: Put 1 on the first layer, 3 in the second layer (arranged in a triangle), 6 in the third layer (arrang...
Blue Bridge Cup 2016 Provincial Tournament [Seventh] -Javab Group Analysis Blue Bridge Cup official explaining video:https://www.lanqiao.cn/courses/2737 Zhen Question Document:https://www.lanqiao.cn/c...
Refer to the junction and official code given by the official website of the Blue Bridge Cup. Blue Bridge Cup official explaining video:https://www.lanqiao.cn/courses/2737 Zhen Question Document:https...
Fill blank questions A. ASC B. Card C. Line D. Food placed E. Path Programming questions F. Time display G. minimum weight H. Yang Hui triangle I. Two-way sort J. Parentheses sequence Fill blank quest...
shopping list Idea: Take out the calculator or calculate the data, pay attention to only 100 at least 100, the result is 5136.85, should take 5200 Answer: 5200 Card triangle Answer: 144 analysis: The ...
The maximum value of each column can be added, and the same person can only take it once. Two cycles use havehset to store different non-empty characters. Iterate the item 20190324 The triple cycle en...
The 4th Blue Bridge Cup Javab Group Provincial Tournament - Revitalizing China Topic description Xiaoming participated in the fun gain of the school, one of which is: jumping. Painted some plaids on t...
Refer to the snippet and official code given by the official website of the Blue Bridge. Blue Bridge Cup official explaining video:https://www.lanqiao.cn/courses/2737 Time: 4 hours A. Week at the end ...
April 18, 2020 Lanqiao Cup Provincial Simulation Tournament Question 1: Problem description: consists of a pair of brackets, which can form a legal bracket sequence: (). consists of 2 pairs of b...