문제 링크입니다: www.acmicpc.net/problem/5554
5554번: 심부름 가는 길
승균이는 매일 학교, PC방, 학원에 다닌다. 반복되는 일상에 익숙해진 승균이는 이동시간을 단축해서 PC방에 더 오래 머물고 싶었다. 그래서 스톱워치를 들고 이동할 때마다 기록을 잰 후 집
www.acmicpc.net
간단한 수학 문제였습니다.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
using namespace std; | |
const int MAX = 4; | |
const int MINUTE_TO_SECOND = 60; | |
void printTimeFormat(int seconds) | |
{ | |
int minute = 0; | |
while (seconds / MINUTE_TO_SECOND) | |
{ | |
seconds -= MINUTE_TO_SECOND; | |
minute++; | |
} | |
cout << minute << "\n"; | |
cout << seconds << "\n"; | |
} | |
int main(void) | |
{ | |
ios_base::sync_with_stdio(0); | |
cin.tie(0); | |
int seconds = 0; | |
for (int i = 0; i < MAX; i++) | |
{ | |
int second; | |
cin >> second; | |
seconds += second; | |
} | |
printTimeFormat(seconds); | |
return 0; | |
} |


개발환경:Visual Studio 2017
지적, 조언, 질문 환영입니다! 댓글 남겨주세요~
반응형
'알고리즘 > BOJ' 카테고리의 다른 글
백준 8437번 Julka (C++) (1) | 2021.03.06 |
---|---|
백준 6749번 Next in line (0) | 2021.03.06 |
백준 5522번 카드 게임 (0) | 2021.03.06 |
백준 3046번 R2 (0) | 2021.03.06 |
백준 3003번 킹, 퀸, 룩, 비숍, 나이트, 폰 (0) | 2021.03.06 |