문제 링크입니다: https://www.acmicpc.net/problem/9161
9161번: Sir Bedavere’s Bogus Division Solutions
The wise Sir Bedavere often uses non-standard logic, yet achieves positive results. Well, it seems he has been at it again, this time with division. He has determined that canceling the common digit of a numerator and denominator produces the correct answe
www.acmicpc.net
111의 배수들은 제외
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 <string> | |
using namespace std; | |
const int MIN = 100; | |
const int MAX = 999; | |
const int OMIT_MOD = 111; | |
bool func(int i, int j) | |
{ | |
return (i * (j % 100) == (i / 10) * j) && (i % 10 == j / 100); | |
} | |
int main(void) | |
{ | |
for (int i = MIN; i <= MAX; i++) | |
{ | |
for (int j = MIN; j <= MAX; j++) | |
{ | |
if (i % OMIT_MOD == 0 && j % OMIT_MOD == 0) | |
{ | |
continue; | |
} | |
if (func(i, j)) | |
{ | |
printf("%d / %d = %d / %d\n", i, j, i / 10, j % 100); | |
} | |
} | |
} | |
return 0; | |
} |


개발환경:Visual Studio 2017
지적, 조언, 질문 환영입니다! 댓글 남겨주세요~
반응형
'알고리즘 > BOJ' 카테고리의 다른 글
백준 9228번 Check Digits (0) | 2021.07.02 |
---|---|
백준 9182번 Biorhythms (0) | 2021.07.01 |
백준 9151번 Starship Hakodate-maru (0) | 2021.06.28 |
백준 9094번 수학적 호기심 (0) | 2021.06.28 |
백준 9085번 더하기 (0) | 2021.06.28 |