Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weโ€™ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

31-SeongHoonC #219

Merged
merged 1 commit into from
Jul 22, 2024
Merged

31-SeongHoonC #219

merged 1 commit into from
Jul 22, 2024

Conversation

SeongHoonC
Copy link
Collaborator

@SeongHoonC SeongHoonC commented Jul 17, 2024

๐Ÿ”— ๋ฌธ์ œ ๋งํฌ

์„ฑ์›์ด์˜ ๋‹ค์ด์–ดํŠธ
๋‹ค์ด์–ดํŠธ

image

โœ”๏ธ ์†Œ์š”๋œ ์‹œ๊ฐ„

30๋ถ„

โœจ ์ˆ˜๋„ ์ฝ”๋“œ

์˜ค๋žœ๋งŒ์— ํ’€๋‹ค๋ณด๋‹ˆ ํˆฌํฌ์ธํ„ฐ๋ฅผ ๋– ์˜ฌ๋ฆฌ๋Š”๋ฐ ์ข€ ๊ฑธ๋ ธ๋„ค์š”.

head = 2
tail = 1

int x = (head + tail) * (head - tail) = head ^ 2 - tail ^ 2 ์ด๊ธฐ ๋•Œ๋ฌธ์—

  1. x ๊ฐ€ G ๋ณด๋‹ค ํฌ๋‹ค๋ฉด tail ์ฆ๊ฐ€
  2. x ๊ฐ€ G ๋ณด๋‹ค ์ž‘๋‹ค๋ฉด head ์ฆ๊ฐ€
  3. x ๊ฐ€ G ์™€ ๊ฐ™๋‹ค๋ฉด ๋ฆฌ์ŠคํŠธ์— ์ถ”๊ฐ€ํ•ฉ๋‹ˆ๋‹ค.

Copy link
Member

@tgyuuAn tgyuuAn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

์•„... ์ด๊ฑฐ ํˆฌํฌ์ธํ„ฐ๋กœ๋„ ํ•ด๊ฒฐํ•  ์ˆ˜ ์žˆ๊ตฐ์š”....?

์ €๋Š” ์ง‘ํ•ฉ ์ž๋ฃŒ๊ตฌ์กฐ ์จ์„œ ๊ทธ๋ƒฅ ๊ณ„์† ์žˆ๋Š”์ง€ ํƒ์ƒ‰ํ–ˆ์–ด์š”...

import math
import sys

def input(): return sys.stdin.readline().rstrip()

G = int(input())
square_numbers_set = set()
square_numbers_list = list()
prev = 0
for step in range(1,100_001):
    now = step**2
    if (now-prev) > G: break
    square_numbers_set.add(now)
    square_numbers_list.append(now)
    prev = now

flag = True
for now in square_numbers_list:
    if now - G in square_numbers_set: 
        flag = False
        print(int(math.sqrt(now)))

if flag: print(-1)
    
# G = ํ˜„์žฌ ๋ชธ๋ฌด๊ฒŒ ^2 - ์›๋ž˜ ๋ชธ๋ฌด๊ฒŒ ^2
# X + G = Y
# G = Y - X

์™€ ํˆฌํฌ์ธํ„ฐ๋กœ๋„ ํ’€ ์ˆ˜ ์žˆ์—ˆ๊ตฐ์š”.. ์™œ ๋ชป๋– ์˜ฌ๋ ธ์ง€....

@SeongHoonC SeongHoonC merged commit b0ec1d1 into main Jul 22, 2024
5 checks passed
@SeongHoonC SeongHoonC deleted the 31-SeongHoonC branch July 22, 2024 12:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants