Algorithm (23.1.5)

2023. 1. 7. 15:51·algorithm

백준 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나 성능개선 알고리즘도 있다고 하니 참고바람

https://st-lab.tistory.com/24

 

[백준] 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
'algorithm' 카테고리의 다른 글
  • Algorithm(23.2.2)
  • Algorithm(23.1.29)
  • Algorithm(23.1.23)
  • Algorithm(23.1.19)
noeyh
noeyh
기록하고 성장하는 개발자, 최유현 입니다. github : https://github.com/Choiyuhyeon
    티스토리 홈 로그아웃
  • noeyh
    CreateU
    noeyh
  • 전체
    오늘
    어제
  • 글쓰기 관리
    GitHub
    Notion
    • 분류 전체보기 (31)
      • web (22)
        • html (5)
        • css (4)
        • js (5)
        • react (6)
        • next (1)
      • server (0)
      • linux (0)
      • figma (0)
      • ml (0)
      • algorithm (5)
      • git (1)
      • 미니프로젝트 (0)
      • 프로젝트 (0)
      • 정보 (0)
      • 일상 (0)
      • memo (1)
  • 블로그 메뉴

    • 홈
    • 태그
    • 방명록
  • 링크

  • 공지사항

  • 인기 글

  • hELLO· Designed By정상우.v4.10.6
noeyh
Algorithm (23.1.5)
상단으로

티스토리툴바