โ์ช ์ ํจ๊ป ํ๋ฃจ์ 30๋ถ ์ด์ ์์โจ
2798
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() : ๋์ ๋ฌธ์์ด์ ํน์ ๋ฌธ์์ด์ด ํฌํจ๋์ด ์๋์ง ํ์ธํ๋ ํจ์์ด๋ค.