Skip to content

Commit

Permalink
[Bronze III] Title: 완전 제곱수, Time: 116 ms, Memory: 114328 KB -BaekjoonHub
Browse files Browse the repository at this point in the history
  • Loading branch information
hmnd1257 committed Jul 17, 2023
1 parent f1a36f5 commit 5e850df
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 0 deletions.
32 changes: 32 additions & 0 deletions 백준/Bronze/6131. 완전 제곱수/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# [Bronze III] 완전 제곱수 - 6131

[문제 링크](https://www.acmicpc.net/problem/6131)

### 성능 요약

메모리: 114328 KB, 시간: 116 ms

### 분류

사칙연산, 브루트포스 알고리즘, 수학

### 문제 설명

<p>상근이는 선영이와 함께 게임을 하고 있다. 먼저, 상근이는 두 양의 정수 A와 B를 고른다. (1 ≤ B ≤ A ≤ 500) 그 다음, 선영이는 상근이가 고른 수를 맞춰야 한다.</p>

<p>상근이는 선영이에게 다음과 같은 힌트를 주었다.</p>

<blockquote>
<p>A의 제곱은 B의 제곱보다 N만큼 커 (1 ≤ N ≤ 1,000)</p>
</blockquote>

<p>위의 힌트 조건을 만족하는 A와 B 쌍의 개수를 구하는 프로그램을 작성하시오.</p>

### 입력

<p>첫째 줄에 N이 주어진다.</p>

### 출력

<p>상근이의 힌트 조건을 만족하는 (A,B) 쌍의 개수를 출력한다. </p>

Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
N = int(input())
cnt = 0
for i in range(1, N):
if i**2 - (i-1)**2 > N:
break
for j in range(1, i+1):
if i**2 - j**2 == N:
cnt += 1
print(cnt)

0 comments on commit 5e850df

Please sign in to comment.