문제 링크입니다: www.acmicpc.net/problem/1598
1598번: 꼬리를 무는 숫자 나열
첫째 줄에 원숭이가 생각한 두 개의 자연수가 주어진다. 각 숫자는 10,000,000 이하이다.
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> | |
#include <algorithm> | |
using namespace std; | |
const int MOD = 4; | |
int main(void) | |
{ | |
ios_base::sync_with_stdio(0); | |
cin.tie(0); | |
int a, b; | |
cin >> a >> b; | |
a--, b--; | |
int aX = a / MOD, aY = a % MOD; | |
int bX = b / MOD, bY = b % MOD; | |
int result = abs(aX - bX) + abs(aY - bY); | |
cout << result << "\n"; | |
return 0; | |
} |


개발환경:Visual Studio 2017
지적, 조언, 질문 환영입니다! 댓글 남겨주세요~
반응형
'알고리즘 > BOJ' 카테고리의 다른 글
백준 1837번 암호제작 (0) | 2021.04.04 |
---|---|
백준 1703번 생장점 (0) | 2021.04.04 |
백준 1547번 공 (0) | 2021.04.04 |
백준 1333번 부재중 전화 (0) | 2021.04.04 |
백준 1284번 집 주소 (0) | 2021.04.04 |