문제 링크입니다: www.acmicpc.net/problem/13136
13136번: Do Not Touch Anything
첫 번째 줄에 좌석의 세로 크기, 가로 크기 R, C와 한 대의 CCTV가 수용할 수 있는 범위 N이 주어진다. (1 ≤ R, C, N ≤ 1,000,000)
www.acmicpc.net
R과 C가 1,000,000이고 N이 1일 경우 답이 1,000,000,000,000이 되기 때문에 int 범위를 벗어납니다.
따라서, long이나 long long 자료형을 써야 AC를 받을 수 있는 문제였습니다.
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; | |
int main(void) | |
{ | |
ios_base::sync_with_stdio(0); | |
cin.tie(0); | |
long long R, C, N; | |
cin >> R >> C >> N; | |
long long row = R / N + (R%N ? 1 : 0); | |
long long col = C / N + (C%N ? 1 : 0); | |
long long result = row * col * 1LL; | |
cout << result << "\n"; | |
return 0; | |
} |


개발환경:Visual Studio 2017
지적, 조언, 질문 환영입니다! 댓글 남겨주세요~
반응형
'알고리즘 > BOJ' 카테고리의 다른 글
백준 13597번 Tri-du (0) | 2021.03.15 |
---|---|
백준 13311번 행운의 편지 (0) | 2021.03.15 |
백준 11948번 과목선택 (0) | 2021.03.15 |
백준 11943번 파일 옮기기 (0) | 2021.03.15 |
백준 11549번 Identifying tea (0) | 2021.03.15 |