# ๐ฅBaekjoon start๐ฅ

arielยท2021๋ 11์ 24์ผ
0

๋ชฉ๋ก ๋ณด๊ธฐ
14/14

# 2021-11-24

โ์ช ์ ํจ๊ป ํ๋ฃจ์ 30๋ถ ์ด์ ์์โจ

#### 2798

https://tooo1.tistory.com/28

import java.util.Scanner;
public class Main {

public static void main(String[] args) {

Scanner sc = new Scanner(System.in);
int N = sc.nextInt();
int M = sc.nextInt();

int[]array = new int[N];

for(int i = 0; i<N; i++) {
array[i] = sc.nextInt();
}

int result = search(array, N, M);
System.out.println(result);
}

static int search(int[] array, int N, int M) {
int result=0;

//์ฒซ๋ฒ์งธ ์นด๋
for(int i =0; i< N -2; i++) {

if(array[i]>M) continue;
//๋๋ฒ์งธ ์นด๋
for(int j = i+1; j< N - 1; j++) {
if(array[i] + array[j] > M) continue;
//์ธ๋ฒ์งธ ์นด๋
for(int k = j+1; k<N; k++) {
// ์ธ์์ ํฉ : temp
int temp = array[i] + array[j] + array[k];
//๋๋ฌ๊ฐ ๋ถ๋ฅธ ์ซ์์ ์ผ์นํ๋ฉด temp return
if(M == temp) {
return temp;
}
if(result < temp && temp < M) {
result = temp;
}
}
}
}

return result;
}
}


#### 2231

import java.util.Scanner;
public class Main {

public static void main(String[] args) {

Scanner sc = new Scanner(System.in);
int N = sc.nextInt();

int result = 0;

for(int i = 0; i<N; i++) {
int number = i;
int sum = 0;//๊ฐ ์๋ฆฟ์ ํฉ ๋ณ์

while(number !=0) {
sum += number%10; //๊ฐ ์๋ฆฟ์ ๋ํ๊ธฐ
number /= 10;
}

//i ๊ฐ๊ณผ ๊ฐ ์๋ฆฟ์ ๋์ ํฉ์ด ๊ฐ์ ๊ฒฝ์ฐ(์์ฑ์๋ฅผ ์ฐพ์์ ๊ฒฝ์ฐ)
if(sum + i == N) {
result = i;
break;
}
}
System.out.println(result);
}

}

#### 7568

import java.util.Scanner;
public class Main {

public static void main(String[] args) {

Scanner sc = new Scanner(System.in);
int N = sc.nextInt();

int[][] arr = new int[N][2];

for(int i = 0; i<N; i++) {
arr[i][0] = sc.nextInt(); //๋ชธ๋ฌด๊ฒ
arr[i][1] = sc.nextInt(); //ํค

}
for(int i=0; i<N; i++) {
int rank = 1;

for(int j=0;j<N; j++) {
if(i == j) continue;//๊ฐ์ ์ฌ๋์ ๋น๊ตํ  ํ์์๋ค
if(arr[i][0] < arr[j][0] && arr[i][1] < arr[j][1]) {
rank++;
}
}
System.out.print(rank + " ");
}
}
}

#### 1018

import java.util.Scanner;
public class Main {

public static boolean[][] arr;
public static int min = 64;

public static void main(String[] args) {

Scanner sc = new Scanner(System.in);
int N = sc.nextInt();
int M = sc.nextInt();

arr = new boolean[N][M];

for(int i= 0; i<N; i++) {
String str = sc.next();

for(int j =0; j<M; j++) {
if(str.charAt(j)=='W') {
arr[i][j] = true; //w์ผ๋๋ true
}else {
arr[i][j] = false;//B์ผ๋๋ false
}
}
}

int N_row = N -7;
int M_col = M -7;

for(int i=0; i< N_row; i++) {
for(int j =0; j<M_col; j++) {
find(i,j);

}
}
System.out.println(min);
}

public static void find(int x, int y) {
int end_x = x+8;
int end_y = y+8;
int count =0;

boolean TF = arr[x][y];//์ฒซ ๋ฒ์งธ ์นธ์ ์

for(int i =x; i<end_x; i++) {
for(int j = y; j<end_y; j++) {

//์ฌ๋ฐ๋ฅธ ์์ด ์๋๊ฒฝ์ฐ count 1์ฆ๊ฐ
if(arr[i][j] != TF) {
count++;
}
//๋ค์ ์นธ์ ์์ด ๋ฐ๋๋ฏ๋ก
//๋ฐ๋๋ก ๊ฐ์ ๋ณ๊ฒฝํ๋ค
TF = (!TF);
}
TF = !TF;
}

count = Math.min(count, 64 - count);

min = Math.min(min, count);
}
}

#### 1436

import java.util.Scanner;
public class Main {

public static void main(String[] args) {

Scanner sc = new Scanner(System.in);
int N = sc.nextInt();

int num = 666;
int count = 1;
while(count !=N) {
num++;

//int ํ์ธ num์ string ์ผ๋ก ๋ณํํ ๋ค, "666"์ด๋ ๋ฌธ์์ด์ด ์๋์ง ๊ฒ์ฌ
if(String.valueOf(num).contains("666")) {
count++;
}
}
System.out.println(num);
}
}

#### [๊ธฐ๋ก]๐

.contains() : ๋์ ๋ฌธ์์ด์ ํน์  ๋ฌธ์์ด์ด ํฌํจ๋์ด ์๋์ง ํ์ธํ๋ ํจ์์ด๋ค.