J1Yun
ZU-TECHLOG
J1Yun
์ „์ฒด ๋ฐฉ๋ฌธ์ž
์˜ค๋Š˜
์–ด์ œ
  • ๐Ÿ“‘ Category (135)
    • Algorithm (61)
      • ๐Ÿ“š Concept (6)
      • ๐Ÿ“˜ Baekjoon Judge (53)
      • ๐Ÿ“— Programmers (2)
    • Computer Science (42)
      • ๐Ÿ”’ Operating System (14)
      • ๐Ÿ“ก Network (15)
      • ๐Ÿ’พ Database (8)
      • ๐Ÿงฉ Design Pattern (4)
      • ๐Ÿ”‘ Security (1)
    • Activities (12)
      • ๐Ÿฆ ๋ฉ‹์Ÿ์ด์‚ฌ์ž์ฒ˜๋Ÿผ 9๊ธฐ (6)
      • ๐Ÿ’ป SW๋งˆ์—์ŠคํŠธ๋กœ 13๊ธฐ (6)
    • Infra (1)
      • โ˜๏ธ AWS (1)
    • Languages (1)
      • ๐Ÿ’™ Python (1)
    • Backend (7)
      • ๐Ÿ”ต Django (4)
      • ๐ŸŸข Node.js (3)
    • Ect. (8)
      • ๐Ÿ’ฌ Talk (0)
      • ๐Ÿ—‚๏ธ ๊ฐœ๋ฐœ์ง๊ตฐ ์ทจ์—… ์ค€๋น„์ž๋ฃŒ (8)

๋ธ”๋กœ๊ทธ ๋ฉ”๋‰ด

  • ํ™ˆ
  • ํƒœ๊ทธ
  • ๋ฐฉ๋ช…๋ก

๊ณต์ง€์‚ฌํ•ญ

์ธ๊ธฐ ๊ธ€

์ตœ๊ทผ ๋Œ“๊ธ€

์ตœ๊ทผ ๊ธ€

ํ‹ฐ์Šคํ† ๋ฆฌ

250x250
hELLO ยท Designed By ์ •์ƒ์šฐ.
J1Yun

ZU-TECHLOG

[BOJ] ๋ฐฑ์ค€ 1789๋ฒˆ ์ˆ˜๋“ค์˜ ํ•ฉ - ํŒŒ์ด์ฌ(Python)
Algorithm/๐Ÿ“˜ Baekjoon Judge

[BOJ] ๋ฐฑ์ค€ 1789๋ฒˆ ์ˆ˜๋“ค์˜ ํ•ฉ - ํŒŒ์ด์ฌ(Python)

728x90

๋ฌธ์ œ

์„œ๋กœ ๋‹ค๋ฅธ N๊ฐœ์˜ ์ž์—ฐ์ˆ˜์˜ ํ•ฉ์ด S๋ผ๊ณ  ํ•œ๋‹ค. S๋ฅผ ์•Œ ๋•Œ, ์ž์—ฐ์ˆ˜ N์˜ ์ตœ๋Œ“๊ฐ’์€ ์–ผ๋งˆ์ผ๊นŒ?

์ž…๋ ฅ

์ฒซ์งธ ์ค„์— ์ž์—ฐ์ˆ˜ S(1 ≤ S ≤ 4,294,967,295)๊ฐ€ ์ฃผ์–ด์ง„๋‹ค.

์ถœ๋ ฅ

์ฒซ์งธ ์ค„์— ์ž์—ฐ์ˆ˜ N์˜ ์ตœ๋Œ“๊ฐ’์„ ์ถœ๋ ฅํ•œ๋‹ค.

 

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

 

1789๋ฒˆ: ์ˆ˜๋“ค์˜ ํ•ฉ

์ฒซ์งธ ์ค„์— ์ž์—ฐ์ˆ˜ S(1 ≤ S ≤ 4,294,967,295)๊ฐ€ ์ฃผ์–ด์ง„๋‹ค.

www.acmicpc.net

 

๐Ÿ’ก ํ’€์ด ๋ฐ ์ฝ”๋“œ

s = int(input())

for i in range(1, s+1):
    if s - i < 0:
        break
    s -= i
    result = i

print(result)

 

์ตœ๋Œ€ํ•œ ์ž‘์€ ์ˆ˜๋ฅผ ๋”ํ•ด์„œ S๋ฅผ ๋งŒ๋“ค์–ด์•ผ์ง€๋งŒ N์ด ์ตœ๋Œ€๊ฐ€ ๋  ์ˆ˜ ์žˆ๋‹ค๋Š” ์•„์ด๋””์–ด๋งŒ ๋– ์˜ฌ๋ฆฌ๋ฉด ์–ด๋ ต์ง€ ์•Š๊ฒŒ ํ’€ ์ˆ˜ ์žˆ๋‹ค.

728x90

'Algorithm > ๐Ÿ“˜ Baekjoon Judge' ์นดํ…Œ๊ณ ๋ฆฌ์˜ ๋‹ค๋ฅธ ๊ธ€

[BOJ] ๋ฐฑ์ค€ 16953๋ฒˆ A๋ฅผ B๋กœ ๋ฐ”๊พธ๊ธฐ (A->B) - ํŒŒ์ด์ฌ(Python)  (0) 2021.08.26
[BOJ] ๋ฐฑ์ค€ 1715๋ฒˆ ์นด๋“œ ์ •๋ ฌํ•˜๊ธฐ - ํŒŒ์ด์ฌ(Python)  (0) 2021.08.26
[BOJ] ๋ฐฑ์ค€ 2473๋ฒˆ ์„ธ ์šฉ์•ก - ํŒŒ์ด์ฌ(Python)  (3) 2021.08.24
[BOJ] ๋ฐฑ์ค€ 2470๋ฒˆ ๋‘ ์šฉ์•ก - ํŒŒ์ด์ฌ(Python)  (0) 2021.08.24
[BOJ] ๋ฐฑ์ค€ 10026๋ฒˆ ์ ๋ก์ƒ‰์•ฝ - ํŒŒ์ด์ฌ(Python)  (0) 2021.07.25
    'Algorithm/๐Ÿ“˜ Baekjoon Judge' ์นดํ…Œ๊ณ ๋ฆฌ์˜ ๋‹ค๋ฅธ ๊ธ€์ด๋‹ค
    • [BOJ] ๋ฐฑ์ค€ 16953๋ฒˆ A๋ฅผ B๋กœ ๋ฐ”๊พธ๊ธฐ (A->B) - ํŒŒ์ด์ฌ(Python)
    • [BOJ] ๋ฐฑ์ค€ 1715๋ฒˆ ์นด๋“œ ์ •๋ ฌํ•˜๊ธฐ - ํŒŒ์ด์ฌ(Python)
    • [BOJ] ๋ฐฑ์ค€ 2473๋ฒˆ ์„ธ ์šฉ์•ก - ํŒŒ์ด์ฌ(Python)
    • [BOJ] ๋ฐฑ์ค€ 2470๋ฒˆ ๋‘ ์šฉ์•ก - ํŒŒ์ด์ฌ(Python)
    J1Yun
    J1Yun
    ๊ฐœ๋ฐœ ๊ด€๋ จ ๊ธฐ์ˆ  ๋ฐ ๊ณต๋ถ€ ๋‚ด์šฉ ๊ธฐ๋ก์žฅ

    ํ‹ฐ์Šคํ† ๋ฆฌํˆด๋ฐ”