백준 2753번 풀이
윤년계산 문제. 기본적인 조건문 연습
import java.util.Scanner;
class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int year = sc.nextInt();
if(year % 4 ==0){
if(year % 400 ==0){
System.out.println("1");
}
else if(year % 100 ==0){
System.out.println("0");
}
else{
System.out.println("1");
}
}
else{
System.out.println("0");
}
}
}
2884번
import java.util.Scanner;
class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int H = sc.nextInt();
int M = sc.nextInt();
int E = 45;
int i;
if(M < E){
H--;
if(H < 0){
H = 23;
}
i = E-M;
System.out.println(H+" "+ (60-i));
}
else
System.out.println(H+" "+ (M-E));
}
}
15분 정도 소요되어서 시간이 꽤나 걸렸다. 혼자 해결하였고, Stringbuffer나 성능개선 알고리즘도 있다고 하니 참고바람
[백준] 2884번 : 알람 시계 - JAVA [자바]
https://www.acmicpc.net/problem/2884 2884번: 알람 시계 문제 상근이는 매일 아침 알람을 듣고 일어난다. 알람을 듣고 바로 일어나면 다행이겠지만, 항상 조금만 더 자려는 마음 때문에 매일 학교를 지각하
st-lab.tistory.com
'algorithm' 카테고리의 다른 글
| Algorithm(23.2.2) (0) | 2023.02.02 |
|---|---|
| Algorithm(23.1.29) (0) | 2023.01.31 |
| Algorithm(23.1.23) (0) | 2023.01.23 |
| Algorithm(23.1.19) (0) | 2023.01.19 |