We will find a way, we always have.

-interstellar

Problem Solving/๋ฐฑ์ค€

[๋ฐฑ์ค€] 1193๋ฒˆ: ๋ถ„์ˆ˜์ฐพ๊ธฐ - ํŒŒ์ด์ฌ

Redddy 2022. 5. 5. 21:06

๐Ÿ”— ๋ฌธ์ œ๋งํฌ : ๋ถ„์ˆ˜์ฐพ๊ธฐ

 

1193๋ฒˆ: ๋ถ„์ˆ˜์ฐพ๊ธฐ

์ฒซ์งธ ์ค„์— X(1 ≤ X ≤ 10,000,000)๊ฐ€ ์ฃผ์–ด์ง„๋‹ค.

www.acmicpc.net

 

๐Ÿ“• ๋ฌธ์ œ ํ’€์ด

๋ฌธ์ œ ํ’€์ด ํ•˜๊ธฐ์ „์— ์กฐ๊ธˆ ์ฃผ์ €๋ฆฌ ์ฃผ์ €๋ฆฌ ํ•˜์ž๋ฉด,,, ์š”์ฆ˜ ์กฐ๊ธˆ ๋ฐ”๋น ์„œ ๊ธ€ ์˜ฌ๋ฆฌ๋Š” ๋นˆ๋„์ˆ˜๊ฐ€ ์กฐ๊ธˆ ์ค„์—ˆ๋‹ค. ๊ทธ๋ž˜๋„ ํ•˜๋ฃจ์— ํ•˜๋‚˜์”ฉ์€ ์˜ฌ๋ฆฌ๋ ค๊ณ  ๋…ธ๋ ฅํ•˜๊ณ  ์žˆ์›€!!!

ํŒŒ์Šค์นผ์˜ ์‚ผ๊ฐํ˜•(?) ๊ณผ ๋น„์Šทํ•œ ๋ฐฉํ–ฅ์œผ๋กœ ์›€์ง์ด๋Š”๋ฐ ํ•œ๋ฒˆ์€ ์˜ค๋ฅธ์ชฝ์œผ๋กœ, ํ•œ๋ฒˆ์€ ์™ผ์ชฝ์œผ๋กœ ์ด๋Ÿฐ์‹์œผ๋กœ ๋ฐ˜๋ณตํ•œ๋‹ค. ๊ทธ๋ฆฌ๊ณ  ๋ถ„์ˆ˜์˜ ์ˆซ์ž๋“ค์€ ๋ถ„์ž + ๋ถ„๋ชจ ๊ฐ’์ด ํ•˜๋‚˜์”ฉ ์ฆ๊ฐ€ํ•œ๋‹ค. ์ด ์ ์„ ์ด์šฉํ•˜์—ฌ ์ฝ”๋“œ๋ฅผ ์งฐ๋‹ค.

 

๐Ÿ’ป ์ฝ”๋“œ

div = [i for i in range(1, 4473)]
n = int(input())
cnt = 1
for d in div:
    if n - d <= 0:
        cnt += 1
        if d%2 == 0:
            print(f"{n}/{cnt-n}")
        else:
            print(f"{cnt-n}/{n}")
        break
    else:
        n -= d
        cnt += 1