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

6-wkdghdwns199 #31

Merged
merged 2 commits into from
Feb 20, 2024
Merged

6-wkdghdwns199 #31

merged 2 commits into from
Feb 20, 2024

Conversation

wkdghdwns199
Copy link
Collaborator

@wkdghdwns199 wkdghdwns199 commented Feb 18, 2024

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

https://www.acmicpc.net/problem/13909

๋ฌธ์ œ
์„œ๊ฐ•๋Œ€ํ•™๊ต ์ปดํ“จํ„ฐ๊ณตํ•™๊ณผ ์‹ค์Šต์‹ค R912ํ˜ธ์—๋Š” ํ˜„์žฌ N๊ฐœ์˜ ์ฐฝ๋ฌธ์ด ์žˆ๊ณ  ๋˜ N๋ช…์˜ ์‚ฌ๋žŒ์ด ์žˆ๋‹ค. 1๋ฒˆ์งธ ์‚ฌ๋žŒ์€ 1์˜ ๋ฐฐ์ˆ˜ ๋ฒˆ์งธ ์ฐฝ๋ฌธ์„ ์—ด๋ ค ์žˆ์œผ๋ฉด ๋‹ซ๊ณ  ๋‹ซํ˜€ ์žˆ์œผ๋ฉด ์—ฐ๋‹ค. 2๋ฒˆ์งธ ์‚ฌ๋žŒ์€ 2์˜ ๋ฐฐ์ˆ˜ ๋ฒˆ์งธ ์ฐฝ๋ฌธ์„ ์—ด๋ ค ์žˆ์œผ๋ฉด ๋‹ซ๊ณ  ๋‹ซํ˜€ ์žˆ์œผ๋ฉด ์—ฐ๋‹ค. ์ด๋Ÿฌํ•œ ํ–‰๋™์„ N๋ฒˆ์งธ ์‚ฌ๋žŒ๊นŒ์ง€ ์ง„ํ–‰ํ•œ ํ›„ ์—ด๋ ค ์žˆ๋Š” ์ฐฝ๋ฌธ์˜ ๊ฐœ์ˆ˜๋ฅผ ๊ตฌํ•˜๋ผ. ๋‹จ, ์ฒ˜์Œ์— ๋ชจ๋“  ์ฐฝ๋ฌธ์€ ๋‹ซํ˜€ ์žˆ๋‹ค.

์˜ˆ๋ฅผ ๋“ค์–ด ํ˜„์žฌ 3๊ฐœ์˜ ์ฐฝ๋ฌธ์ด ์žˆ๊ณ  3๋ช…์˜ ์‚ฌ๋žŒ์ด ์žˆ์„ ๋•Œ,

1๋ฒˆ์งธ ์‚ฌ๋žŒ์€ 1์˜ ๋ฐฐ์ˆ˜์ธ 1,2,3๋ฒˆ ์ฐฝ๋ฌธ์„ ์—ฐ๋‹ค. (1, 1, 1)
2๋ฒˆ์งธ ์‚ฌ๋žŒ์€ 2์˜ ๋ฐฐ์ˆ˜์ธ 2๋ฒˆ ์ฐฝ๋ฌธ์„ ๋‹ซ๋Š”๋‹ค. (1, 0, 1)
3๋ฒˆ์งธ ์‚ฌ๋žŒ์€ 3์˜ ๋ฐฐ์ˆ˜์ธ 3๋ฒˆ ์ฐฝ๋ฌธ์„ ๋‹ซ๋Š”๋‹ค. (1, 0, 0)
๊ฒฐ๊ณผ์ ์œผ๋กœ ๋งˆ์ง€๋ง‰์— ์—ด๋ ค ์žˆ๋Š” ์ฐฝ๋ฌธ์˜ ๊ฐœ์ˆ˜๋Š” 1๊ฐœ ์ด๋‹ค.

์ž…๋ ฅ
์ฒซ ๋ฒˆ์งธ ์ค„์—๋Š” ์ฐฝ๋ฌธ์˜ ๊ฐœ์ˆ˜์™€ ์‚ฌ๋žŒ์˜ ์ˆ˜ N(1 โ‰ค N โ‰ค 2,100,000,000)์ด ์ฃผ์–ด์ง„๋‹ค.

์ถœ๋ ฅ
๋งˆ์ง€๋ง‰์— ์—ด๋ ค ์žˆ๋Š” ์ฐฝ๋ฌธ์˜ ๊ฐœ์ˆ˜๋ฅผ ์ถœ๋ ฅํ•œ๋‹ค.

์˜ˆ์ œ ์ž…๋ ฅ 1
3
์˜ˆ์ œ ์ถœ๋ ฅ 1
1

์˜ˆ์ œ ์ž…๋ ฅ 2
24
์˜ˆ์ œ ์ถœ๋ ฅ 2
4

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

1์‹œ๊ฐ„ - ์–ด๋–ค ํŒจํ„ด์ด ์žˆ๋Š”์ง€ ์ดํ•ด๊ฐ€ ๋˜์ง€ ์•Š์•„ ๊ณ ๋ฏผํ•˜๋Š” ์‹œ๊ฐ„์ด ๊ธธ์—ˆ์Šต๋‹ˆ๋‹ค..! ๊ฒ€์ƒ‰์œผ๋กœ ์ฐพ์•„๋‚ธ ๊ธฐ๊ฐ€ ๋ง‰ํžŒ ํ’€์ด๋ฒ•..

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

N ๋ฒˆ์งธ ์‚ฌ๋žŒ์ด ๋ฐฐ์ˆ˜ ๋ฒˆ์งธ ์ฐฝ๋ฌธ์„ ์—ฐ๋‹ค๋Š” ๋ฌธ์ œ์—ฌ์„œ ์•ฝ์ˆ˜๋กœ ํ’€์ด๋ฅผ ํ•ด๋ณผ ์ƒ๊ฐ์„ ๋ชปํ–ˆ์Šต๋‹ˆ๋‹ค.

์ฐฝ๋ฌธ์˜ ์ƒํƒœ๋Š” ์•ฝ์ˆ˜์˜ ๊ฐœ์ˆ˜์™€ ์ƒ๊ด€์ด ์žˆ์—ˆ์Šต๋‹ˆ๋‹ค. ๋งˆ์ง€๋ง‰์— ์—ด๋ ค ์žˆ๋Š” ์ฐฝ๋ฌธ์€ ์•ฝ์ˆ˜์˜ ๊ฐœ์ˆ˜๊ฐ€ ํ™€์ˆ˜์ธ ์ˆซ์ž๋ผ๋Š” ๊ฒƒ์„ ๋‹ค์Œ๊ณผ ๊ฐ™์ด ์•Œ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

  1. ๋‹ซํ˜€์žˆ์œผ๋ฉด ์—ด๊ณ , ์—ด๋ ค์žˆ์œผ๋ฉด ๋‹ซ๋Š”๋‹ค.
  2. N๋ฒˆ์งธ ์ฐฝ๋ฌธ, ์•ฝ์ˆ˜์˜ ๊ฐœ์ˆ˜๊ฐ€ ํ™€์ˆ˜์ด๋ฉด ์—ด๊ณ  -> ๋‹ซ๊ณ  -> ์—ด๊ธฐ ๋•Œ๋ฌธ์—, ์•ฝ์ˆ˜์˜ ๊ฐœ์ˆ˜๊ฐ€ ํ™€์ˆ˜์ด๋ฉด ๋งˆ์ง€๋ง‰์—๋Š” ์—ด๋ฆฐ๋‹ค๋Š” ๋œป์ด๋‹ค.

๊ทธ๋Ÿผ ์•ฝ์ˆ˜๊ฐ€ ํ™€์ˆ˜์ธ ๊ฒƒ์„ ์–ด๋–ป๊ฒŒ ์ฐพ์„ ์ˆ˜ ์žˆ์„๊นŒ์š”.
1,4,9,16,25... ์ด๋“ค์˜ ๊ณตํ†ต์ ์€ ์•ฝ์ˆ˜๊ฐ€ ํ™€์ˆ˜์ด๊ณ , ์ œ๊ณฑ์ˆ˜๋ผ๋Š” ๊ฒƒ์ž…๋‹ˆ๋‹ค. ์‰ฝ๊ฒŒ ๋งํ•ด์„œ ์ œ๊ณฑ๊ทผ์˜ ๊ฐœ์ˆ˜๋ฅผ ๊ตฌํ•˜๋ฉด, ์ฐฝ๋ฌธ์˜ ์—ด๋ ค์žˆ๋Š” ๊ฐœ์ˆ˜๋ฅผ ๊ตฌํ•  ์ˆ˜ ์žˆ๋‹ค๋Š” ๋ง์ด ๋ฉ๋‹ˆ๋‹ค.

๊ทธ๋ž˜์„œ ์ฝ”๋“œ๋Š” ๋”ฑ ๋‘ ์ค„๋กœ ๋งŒ๋“ค ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

import math
N = int(input())
print(int(math.sqrt(N)))

๐Ÿ“š ์ƒˆ๋กญ๊ฒŒ ์•Œ๊ฒŒ๋œ ๋‚ด์šฉ

@alstjr7437
Copy link
Member

alstjr7437 commented Feb 18, 2024

๋ฌด์„œ์šด ์‚ฌ์‹ค - ์•ฝ์ˆ˜๊ฐ€ ํ™€์ˆ˜์ธ ์ˆ˜๋Š” ์ œ๊ณฑ์ˆ˜๋ผ๋Š” ๊ฒƒ ์•„์‹œ๋‚˜์š”!?
6, 8, 10 ๋“ฑ์˜ ์ˆ˜๋Š” ๋‘ ์ˆ˜๊ฐ€ ์ง์„ ์ด๋ฃจ์–ด์„œ 6(2,3) 8(2,4) ๊ณฑํ•ด์ง€๋ฏ€๋กœ ์•ฝ์ˆ˜์˜ ๊ฐœ์ˆ˜๊ฐ€ ์ง์ˆ˜์ธ๋ฐ
4, 9, 16 ๋“ฑ์˜ ์ˆ˜๋Š” 4(2)์™€ 9(3) ๋“ฑ์˜ ์ œ๊ณฑ์œผ๋กœ ๋˜์„œ ์•ฝ์ˆ˜์˜ ๊ฐœ์ˆ˜๊ฐ€ ํ™€์ˆ˜๊ฐ€ ๋˜์„œ
๊ฒฐ๋ก ์€ ์•ฝ์ˆ˜์˜ ๊ฐœ์ˆ˜๊ฐ€ ํ™€์ˆ˜์ธ ์ˆ˜๋Š” ์ œ๊ณฑ์ˆ˜๋ผ๋Š” ๊ฒƒ์ž…๋‹ˆ๋‹ค!

๊ทธ๋ฆฌ๊ณ  ๋„ˆ๋ฌด ์ˆ˜ํ•™ ๊ตฌํ˜„์ชฝ์„ ๋งŽ์ด ํ‘ธ์‹  ๊ฒƒ ๊ฐ™์€๋ฐ ๋‹ค๋ฅธ ์•Œ๊ณ ๋ฆฌ์ฆ˜ ๋ฌธ์ œ๋„ ํ’€์–ด๋ณด์‹œ๋Š”๊ฑด ์–ด๋–จ๊นŒ์š”?!

@tgyuuAn tgyuuAn marked this pull request as ready for review February 19, 2024 14:12
@tgyuuAn
Copy link
Member

tgyuuAn commented Feb 19, 2024

@alstjr7437

๊ทธ๋ฆฌ๊ณ  ๋„ˆ๋ฌด ์ˆ˜ํ•™ ๊ตฌํ˜„์ชฝ์„ ๋งŽ์ด ํ‘ธ์‹  ๊ฒƒ ๊ฐ™์€๋ฐ ๋‹ค๋ฅธ ์•Œ๊ณ ๋ฆฌ์ฆ˜ ๋ฌธ์ œ๋„ ํ’€์–ด๋ณด์‹œ๋Š”๊ฑด ์–ด๋–จ๊นŒ์š”?!

๐Ÿ‘๐Ÿ‘๐Ÿ‘๐Ÿ‘

@wkdghdwns199
Copy link
Collaborator Author

๋ฐฑ์ค€ ๋ฌธ์ œ ๋‹จ๊ณ„๋ณ„๋กœ ํ’€๊ธฐ๋ฅผ ํ•˜๊ณ  ์žˆ๋Š”๋ฐ ์ˆ˜ํ•™ ๊ตฌํ˜„ ์ชฝ์—์„œ ๋„ˆ๋ฌด ์‹œ๊ฐ„์„ ๋งŽ์ด ์žก์•„๋จน์—ˆ๋„ค์š” ใ…œใ…œ ์ด์ œ ์Šฌ์Šฌ ์•Œ๊ณ ๋ฆฌ์ฆ˜ ๋ฌธ์ œ๋กœ ๋„˜์–ด๊ฐˆ ์ฐธ์ด์—ˆ์Šต๋‹ˆ๋‹ค ใ…‹ใ…‹

Copy link
Member

@fnzksxl fnzksxl left a comment

Choose a reason for hiding this comment

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

ํ™์ค€๋‹˜ PR ๋ณผ ๋•Œ๋งˆ๋‹ค ๋จธ๋ฆฌ๊ฐ€ ์ชผ๊ฐœ์ง€๋Š” ๊ฒƒ ๊ฐ™๋”๋‹ˆ.. ์ˆ˜ํ•™ ๊ตฌํ˜„์ด ๋งŽ์•„์„œ ๊ทธ๋Ÿฐ ๊ฑฐ์˜€๊ตฐ์š” ใ…‹ใ…‹ใ…‹ใ…‹ใ…‹ ์ €๋Š” ์—ฌ๊ธฐ์„œ ๊นŒ๋จน์—ˆ๋˜ ๊ฐœ๋… ๋ณต์Šตํ•˜๋Š” ๋Š๋‚Œ์ด๋ผ ์ข‹์Šต๋‹ˆ๋‹ค. ํ’€์ด ์ž˜ ๋ดค์–ด์š”!

@wkdghdwns199 wkdghdwns199 merged commit db22a6a into main Feb 20, 2024
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.

4 participants