반응형
5928번: Contest Timing
Bessie the cow is getting bored of the milk production industry, and wants to switch to an exciting new career in computing. To improve her coding skills, she decides to compete in the on-line USACO competitions. Since she notes that the contest starts on
www.acmicpc.net
시간계산 문제였습니다.
풀이방법
1. 0일 0분 0시를 기점으로 11월 11일 오전 11시 11분을 분단위로 계산합니다.
2. 마찬가지로 contest가 끝난 시간을 계산합니다.
3. 2번 값 - 1번값이 흐른 분의 값(답)입니다.
* 3번에서 구한 값이 음수라면 -1을 출력합니다.
Code
#include <bits/stdc++.h>
using namespace std;
int d,h,m;
int main(){
cin >> d >> h >> m;
int pivot = 11 + 11 * 60 + 11 * 60 * 24;
int ans = m + h * 60 + d * 60 * 24 - pivot;
if(ans < 0 ) cout << -1 <<'\n';
else cout << ans <<'\n';
}
'Algorithm > Implementation' 카테고리의 다른 글
(C++) - 프로그래머스(월간 코드 챌린지 시즌 1) : 삼각 달팽이 답 (0) | 2021.02.01 |
---|---|
(C++) - 백준(BOJ) 2346번 : 풍선 터뜨리기 답 (0) | 2021.01.31 |
(C++) - 백준(BOJ) 3986번 : 좋은 단어 (0) | 2021.01.20 |
(Python) - 백준(BOJ) 2338번 : 긴자리 계산 답 (0) | 2021.01.20 |
(C++) - 백준(BOJ) 1935번 : 후위 표기식 2 답 (0) | 2021.01.15 |