회원가입
로그인
Toggle navigation
문제
문제
전체 문제
문제 출처
단계별로 풀어보기
알고리즘 분류
추가된 문제
문제 순위
문제
푼 사람이 한 명인 문제
아무도 못 푼 문제
최근 제출된 문제
최근 풀린 문제
랜덤
출처
ICPC
Olympiad
한국정보올림피아드
한국정보올림피아드시․도지역본선
전국 대학생 프로그래밍 대회 동아리 연합
대학교 대회
카카오 코드 페스티벌
Coder's High
ICPC
Regionals
World Finals
Korea Regional
Africa and the Middle East Regionals
Europe Regionals
Latin America Regionals
North America Regionals
South Pacific Regionals
문제집
대회
채점 현황
게시판
그룹
더 보기
재채점 기록
블로그
도움말
전체
공지
자유
질문
오타/오역/요청
게시판 공지
홍보
업데이트
solved.ac
글쓰기
질문 도움말
자주묻는 질문
반례 질문있습니다...!
12840번 - 창용이의 시계
qqoxmaos
2년 전
0
여러가지 넣어보았을 땐 , 잘 작동합니다..
어떤 반례가 있을지 알려주십시오...!
import java.util.Scanner; public class Main { static Scanner sc = new Scanner(System.in); static int H = sc.nextInt(); static int M = sc.nextInt(); static int S = sc.nextInt(); static int Q = sc.nextInt(); public static void main(String[] args) { for (int i = 0; i < Q; i++) { int T = sc.nextInt(); if (T == 3) { printNow(); } else { updateTime(T, sc.nextInt()); } } sc.close(); } private static void updateTime(int type, int sec) { int tempH = 0; int tempM = 0; int tempS = 0; if (sec >= 3600) { tempH += sec / 3600; sec %= 3600; } if (sec >= 60) { tempM += sec / 60; sec %= 60; } if (sec >= 60) { sec -= 60; tempS = sec; tempM++; if (tempM >= 60) { tempM -= 60; tempH++; if (tempH >= 24) { tempH -= 24; } } } else { tempS = sec; } if (type == 1) { forwardTime(tempH, tempM, tempS); } else { rewindTime(tempH, tempM, tempS); } } private static void forwardTime(int tempH, int tempM, int tempS) { S += tempS; M += tempM; H += tempH; if (S >= 60) { M++; S -= 60; } if (M >= 60) { H++; M -= 60; } if (H >= 24) { H -= 24; } } private static void rewindTime(int tempH, int tempM, int tempS) { S -= tempS; M -= tempM; H -= tempH; if (S < 0) { S += 60; M--; } if (M < 0) { M += 60; H--; } if (H < 0) { H += 24; } } private static void printNow() { System.out.println(H + " " + M + " " + S); } }
댓글을 작성하려면
로그인
해야 합니다.
qqoxmaos 2년 전
여러가지 넣어보았을 땐 , 잘 작동합니다..
어떤 반례가 있을지 알려주십시오...!