문제
https://www.acmicpc.net/problem/2884
반례
입력 0 45
출력 0 0
풀이
더보기
using System;
namespace AlgorithmTest
{
class cSharpPractice
{
static void Main()
{
string[] time = Console.ReadLine().Split(" ");
int h = Int32.Parse(time[0]);
int m = Int32.Parse(time[1]);
int total_m = (h == 0) ? (24 * 60 + m) : (h * 60 + m);
int early_time = total_m - 45;
int early_h = early_time / 60;
int early_m = early_time % 60;
early_h = (early_h == 24) ? 0 : early_h;
Console.WriteLine($"{early_h} {early_m}");
}
}
}
Comment
왜 틀렸나 처음엔 몰랐는데 반례를 생각 못했다.
문제에서 범위를 잘 확인하자.
참고
'프로그래밍 문제' 카테고리의 다른 글
[백준][C#] 1072번, 게임 (0) | 2024.09.12 |
---|---|
[백준][C#] 1260번, DFS와 BFS (0) | 2024.09.10 |
[백준][C#] 15552번, 빠른 A+B (0) | 2023.10.12 |
[백준][C#] 2480번, 주사위 세개 (0) | 2023.10.12 |
[백준][C#] 2525번, 오븐 시계 (1) | 2023.10.12 |