IT
[JAVA] 백준 2556, 10798, 2903, 2869, 5086, 11653
%?
2025. 5. 3. 14:45
[백준 2556]
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
int array[][] = new int[9][9];
int maxNumber = -1;
int maxRow = 0;
int maxCol = 0;
boolean flag = true;
for (int i = 0; i < 9; i++) {
for (int j = 0; j < 9; j++) {
array[i][j] = input.nextInt();
if (array[i][j] >= 100 || array[i][j] < 0) {
flag = false;
break;
}
}
if (!flag) {
break;
}
}
if (flag) {
for (int i = 0; i < 9; i++) {
for (int j = 0; j < 9; j++) {
if (array[i][j] == maxNumber) {
continue;
} else if (array[i][j] > maxNumber) {
maxNumber = array[i][j];
maxRow = i + 1;
maxCol = j + 1;
}
}
}
System.out.println(maxNumber);
System.out.println(maxRow + " " + maxCol);
} else {
System.out.println("Invalid input");
}
input.close();
}
}
[백준10798]
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
char array[][] = new char[15][5];
boolean flag = false;
for (int i = 0; i < 5; i++) {
String str = input.nextLine();
char c = str.charAt(str.length() - 1);
flag = false;
if (c >= 'a' && c <= 'z' || c >= 'A' && c <= 'Z' || c >= '0' && c <= '9') {
if (str.length() <= 15) {
for (int j = 0; j < str.length(); j++) {
array[j][i] = str.charAt(j);
}
}
flag = true;
}
}
if (flag) {
for (int i = 0; i < array.length; i++) {
for (int j = 0; j < 5; j++) {
if (array[i][j] != 0) {
System.out.print(array[i][j]);
}
}
}
} else {
System.out.println("Invalid input");
}
input.close();
}
}
[백준2903]
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
int N = input.nextInt();
System.out.println((int)Math.pow(Math.pow(2, N) + 1, 2));
input.close();
}
}
[백준2869]
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
int A = input.nextInt();
int B = input.nextInt();
int V = input.nextInt();
if (1 <= B && B < A && A <= V && V <= 1000000000) {
int days = (V - B) / (A - B);
if ((V - B) % (A - B) != 0) days++;
System.out.println(days);
}
input.close();
}
}
[백준5086]
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
while (true) {
int first = input.nextInt();
int second = input.nextInt();
if (first == 0 && second == 0)
break;
else if (first <= 10000 && second <= 10000 && first != second) {
if (second % first == 0)
System.out.println("factor");
else if (first % second == 0)
System.out.println("multiple");
else
System.out.println("neither");
}
}
input.close();
}
}
[백준11653]
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
int N = input.nextInt();
int i = 2;
if (1 <= N && N <= 10000000) {
if (N < 1)
System.out.println(N);
else {
while (N > 1) {
if (N % i == 0) {
System.out.println(i);
N /= i;
} else
i++;
}
}
}
input.close();
}
}
`백준2869 - 달팽이는 올라가고 싶다` 는 for문 밖에 생각이 안 나, 아래 블로그의 코드를 사용하였습니다.
[백준] 2869번 : 달팽이는 올라가고 싶다 - JAVA [자바]
https://www.acmicpc.net/problem/2869 2869번: 달팽이는 올라가고 싶다 문제 땅 위에 달팽이가 있다. 이 달팽이는 높이가 V미터인 나무 막대를 올라갈 것이다. 달팽이는 낮에 A미터 올라갈 수 있다. 하지만,
st-lab.tistory.com