문제 링크입니다: https://www.acmicpc.net/problem/6131
6131번: 완전 제곱수
상근이는 선영이와 함께 게임을 하고 있다. 먼저, 상근이는 두 양의 정수 A와 B를 고른다. (1 ≤ B ≤ A ≤ 500) 그 다음, 선영이는 상근이가 고른 수를 맞춰야 한다. 상근이는 선영이에게 다음과 같
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 = 500; | |
int main(void) | |
{ | |
ios_base::sync_with_stdio(0); | |
cin.tie(0); | |
int N; | |
cin >> N; | |
int result = 0; | |
for (int i = 1; i <= MAX; i++) | |
{ | |
for (int j = i + 1; j <= MAX; j++) | |
{ | |
if (j * j == i * i + N) | |
{ | |
result++; | |
} | |
} | |
} | |
cout << result << "\n"; | |
return 0; | |
} |


개발환경:Visual Studio 2017
지적, 조언, 질문 환영입니다! 댓글 남겨주세요~
반응형
'알고리즘 > BOJ' 카테고리의 다른 글
백준 6162번 Superlatives (0) | 2021.05.29 |
---|---|
백준 6139번 Speed Reading (0) | 2021.05.29 |
백준 6060번 Wheel Rotation (0) | 2021.05.29 |
백준 5751번 Head or Tail (0) | 2021.05.29 |
백준 5717번 상근이의 친구들 (0) | 2021.05.29 |