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

7-pu2rile #26

Merged
merged 4 commits into from
Jul 11, 2024
Merged

7-pu2rile #26

merged 4 commits into from
Jul 11, 2024

Conversation

pu2rile
Copy link
Collaborator

@pu2rile pu2rile commented May 10, 2024

πŸ”— 문제 링크

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

βœ”οΈ μ†Œμš”λœ μ‹œκ°„

25λΆ„

✨ μˆ˜λ„ μ½”λ“œ

  1. 문제 μš”μ•½
  • 666이 λ“€μ–΄κ°€λŠ” N번째 큰 수λ₯Ό μ°ΎλŠ” 것
  • 주의) 5666 λ‹€μŒμœΌλ‘œ 큰 μˆ˜λ“€μ€ 6660, 6661, 6662, ... ν˜•νƒœλ‘œ 증가
  1. μ•Œκ³ λ¦¬μ¦˜
  • 반볡문 속 쑰건문을 톡해 six 값에 '666'이 ν¬ν•¨λ˜λŠ”μ§€λ₯Ό νŒλ‹¨
  • '666'이 ν¬ν•¨λ˜μ–΄ μžˆμ„ 경우 cnt λ³€μˆ˜λ₯Ό 1μ”© 증가
  • six 값을 1μ”© μ¦κ°€μ‹œμΌœ cnt의 μˆ˜κ°€ n이 될 λ•ŒκΉŒμ§€ λ°˜λ³΅ν•œ λ’€ cnt == n이면 반볡문 νƒˆμΆœ

πŸ–₯️ μ½”λ“œ

n = int(input())
cnt = 0
six = 666
while True:
    if '666' in str(six):
        cnt += 1
    if cnt == n:
        break
    
    six += 1

print(six)

πŸ“š μƒˆλ‘­κ²Œ μ•Œκ²Œλœ λ‚΄μš©

Copy link
Member

@oesnuj oesnuj left a comment

Choose a reason for hiding this comment

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

if '666' in str(six): νŒŒμ΄μ¬μ€ μ΄λ ‡κ²Œν•΄μ„œ str에 νŠΉμ • λ¬Έμžκ°€ μžˆμŒμ„ 찾을 수 μžˆκ΅°μš”..!
저도 λ¬Έμžμ—΄ 라이브러리 κΈ°λŠ₯을 μ¨μ„œ ν’€μ—ˆλŠ”λ° 라이브러리 κΈ°λŠ₯을 μ•ˆμ“°κ³  ν‘ΈλŠ” λ°©λ²•λ„μžˆλ”λΌκ΅¬μš”
666κ°€ μ‘΄μž¬ν•˜λŠ” μˆ˜μΈμ§€ ν™•μΈν•˜κΈ° μœ„ν•΄ λ§ˆμ§€λ§‰ 자릿수λ₯Ό 반볡적으둜 μ œκ±°ν•˜λŠ” λ°©λ²•μž…λ‹ˆλ‹€.
이번 PR도 μˆ˜κ³ ν•˜μ…¨μŠ΅λ‹ˆλ‹€πŸ‘

int main()
{
	cin >> N;

	ans = 0; // μ˜ν™” 제λͺ©
	cnt = 0; // ν˜„μž¬ λͺ‡λ²ˆμ¨° μ’…λ§μ˜ μˆ˜μΈμ§€

	while (cnt != N)
	{
		ans++;
		temp = ans;

		// μˆ˜μ— 6이 적어도 3κ°œμ΄μƒ λ“€μ–΄κ°€λŠ”μ§€ νŒλ³„
		while (temp != 0)
		{
			if (temp % 1000 == 666) // μ’…λ§μ˜ 숫자라면
			{
				cnt++;
				break;
			}
			else temp /= 10; // 일의 자리수 μ‚­μ œ
		}
	}
	cout << ans;
}
`

Copy link
Collaborator

@suhyun113 suhyun113 left a comment

Choose a reason for hiding this comment

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

λ¬Έμ œκ°€ 이해가 된 쀄 μ•Œκ³  곧μž₯ ν’€μ–΄λ΄€λ‹€κ°€ λ„ˆλ¬΄ λ‹¨μˆœν•˜κ²Œ μƒκ°ν•΄μ„œ...λ§ν–ˆλ„€μš”... μƒκ°ν•œκ±°λž‘ 많이 λ‹¬λžμ–΄μš”..κ·Έλž˜μ„œ λ„ν˜„λ‹˜ μ½”λ“œ λ³΄λ©΄μ„œ 천천히 이해해봀어.. μ²˜μŒμ— μž…λ ₯λ°›λŠ” μˆ«μžμ— 따라 666μ•žμ˜ 숫자만 계속 μ¦κ°€λ§Œ ν•˜λŠ” 건쀄 μ•Œκ³  λ¬Έμ œκ°€ μ’€ μ΄μƒν•˜λ‹€κ³  μƒκ°ν•˜κΈ΄ ν–ˆλŠ”λ°..λ°”λ³΄κ°™μ•˜μ–΄μš”πŸ˜­ κ·Έλƒ₯ 666μ•žμ— N-1의 숫자만 λΆ™μ—¬μ£Όλ©΄ λ˜λŠ” 쀄 μ•Œμ•˜λŠ”λ°, λ„ν˜„λ‹˜μ΄ 주의)둜 적어둔 λΆ€λΆ„μ²˜λŸΌ 그런 μˆ˜λ“€λ„ λœλ‹€λŠ” κ±Έ...κ°„κ³Όν–ˆλ„€μš”.

666이 λ“€μ–΄κ°„ 제λͺ©μ˜ μ˜ν™”λ₯Ό μ°ΎλŠ”λ‹€λŠ”κ±Έ μ œλŒ€λ‘œ μ΄ν•΄ν•œκ²Œ μ’€ λŠ¦μ—ˆμ–΄μš”... 666이 듀어가지 μ•Šμ•˜μœΌλ©΄ μ›ν•˜λŠ” 제λͺ©μ΄ μ•„λ‹ˆλ‹ˆκΉŒ 또 μ¦κ°€μ‹œν‚€κ³  κ³„μ†ν•΄μ„œ λ°˜λ³΅ν•˜λ‹€κ°€ 카운트 νšŸμˆ˜κ°€ nκ³Ό κ°™μœΌλ©΄ λ°”λ‘œ 좜λ ₯ν•˜λ©΄ λ˜λŠ” κ΅¬μ‘°μ˜€κ΅°μš”! 생각보닀 μ €ν•œν…ŒλŠ” λ¬Έμ œκ°€ 잘 μ΄ν•΄ν•˜κΈ° νž˜λ“€μ—ˆμ–΄μš”.. κ·Έλž˜λ„ 계속 λ³΄λ‹ˆκΉŒ μ΄ν•΄λŠ” λ˜λŠ”κ΅°μš”.

ν™•μ‹€νžˆ νŒŒμ΄μ¬μ€ νŠΉμ • 문자λ₯Ό μ°ΎλŠ” 것이 맀우 νŽΈλ¦¬ν•œ 것 κ°™μ•„μš”
666을 가지고 μžˆλŠ”μ§€λ₯Ό if '666' in str(six): 만으둜 κ°€λŠ₯ν•˜λ‹ˆκΉŒμš”γ…Ž

λ”°λ‘œ μ•Œμ•„λ³΄λ‹ˆ μ΄λ ‡κ²Œ κ°€μž₯ μž‘μ€ μ’…λ§μ˜ 숫자인 666λΆ€ν„° μ‹œμž‘ν•΄μ„œ λ‹¨μˆœνžˆ 숫자λ₯Ό ν•˜λ‚˜μ”© μ¦κ°€μ‹œμΌœλ‚˜κ°€λ©° λ‹€λ₯Έ μ’…λ§μ˜ 숫자λ₯Ό μ°ΎλŠ” λ°©μ‹μ˜ μ•Œκ³ λ¦¬μ¦˜μ„ **'브루트포슀 μ•Œκ³ λ¦¬μ¦˜'**이라고 ν•œλ‹€κ³  ν•©λ‹ˆλ‹€! κ°€λŠ₯ν•œ λͺ¨λ“  경우의 수λ₯Ό λͺ¨λ‘ νƒμƒ‰ν•˜λŠ” μ•Œκ³ λ¦¬μ¦˜μ΄λ„€μš”.
PR μˆ˜κ³ ν•˜μ…¨μŠ΅λ‹ˆλ‹ΉπŸ§

@pu2rile pu2rile merged commit 25c0a04 into main Jul 11, 2024
@pu2rile pu2rile deleted the 7-pu2rile branch July 11, 2024 12:33
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.

3 participants