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

3-yuyu0830 #12

Closed
wants to merge 2 commits into from
Closed

3-yuyu0830 #12

wants to merge 2 commits into from

Conversation

yuyu0830
Copy link
Collaborator

πŸ”— 문제 링크

οΏ½ν•˜μ΄νΌ ν† λ§ˆν† 

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

1μ‹œκ°„ 반

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

ν”„λ‘œκ·Έλž˜λ°μ„ κ°“ μ‹œμž‘ν•œ 무렡, μ €μ—κ²ŒλŠ” μž‘μ€ 꿈이 μžˆμ—ˆμŠ΅λ‹ˆλ‹€. 그건 λ°”λ‘œ 100쀑 for문을 μ“°λŠ” κ²ƒμ΄μ˜€μŠ΅λ‹ˆλ‹€. ν•œ forλ¬Έ λ‹Ή 2νšŒμ”© λ°˜λ³΅ν•΄λ„ 2^100회 μ‹€ν–‰λ˜λ„€μš”.. μ½”λ¦°μ΄μ˜ μž‘μ€ κΏˆμ΄μ˜€μŠ΅λ‹ˆλ‹€.

이번 ν•˜μ΄νΌ ν† λ§ˆν† λ₯Ό 처음 보고 처음 λ“  생각은 μ•„ 이거 11쀑 forλ¬Έ 각이닀 μ˜€μŠ΅λ‹ˆλ‹€. ν•˜μ§€λ§Œ λ„μ €νžˆ 생각해도 μŠ€λ§ˆνŠΈν•œ 해결법은 μ•„λ‹Œ 것 κ°™μ•„ ν¬κΈ°ν–ˆμŠ΅λ‹ˆλ‹€.

그러던 와쀑 μ˜ˆμ „μ— μˆμ½”λ”©μ„ ν•  λ•Œ n * m 크기의 이차원 λ°°μ—΄ 값을 μ²˜λ¦¬ν•  λ•Œ
for (int i = 0; i < n * m; i++) cin >> arr[i / n][i % n]; μ΄λ ‡κ²Œ 받은 기얡이 λ‚˜μ„œ μ‘μš©ν•˜κ²Œ λ˜μ—ˆμŠ΅λ‹ˆλ‹€.

m * n * o * p * q * r * s * t * u * v * w 의 크기가 10^6 μ΄ν•˜λ‹ˆ 10^6+1 크기의 1차원 배열을 μ‚¬μš©ν–ˆμŠ΅λ‹ˆλ‹€.

이후 차원 크기가 1인 κ²½μš°λŠ” λ¬΄μ‹œν•΄λ„ λ˜λ‹ˆ νŒ¨μŠ€ν•˜κ³ , 크기가 μ‘΄μž¬ν•˜λŠ” κ²½μš°λŠ” len 배열에 μ°¨μ›μ˜ 크기λ₯Ό μ €μž₯ν•˜κ³  dimension λ³€μˆ˜μ˜ 값을 1 더해 차수λ₯Ό μ €μž₯ν–ˆμŠ΅λ‹ˆλ‹€.

1차원 λ°°μ—΄μ—μ„œμ˜ μœ„μΉ˜ i의 m차원 λ°°μ—΄ μƒμ˜ 값은 i / (n * o * p * q * r * s * t * u * v * w) κ°€ λ©λ‹ˆλ‹€. λ§ˆμ°¬κ°€μ§€λ‘œ 'n차원 λ°°μ—΄' μƒμ˜ 값은 i / o * p * q * r * s * t * u * v * w) κ°€ λ©λ‹ˆλ‹€. λ¬Όλ‘  μ •ν™•ν•œ μœ„μΉ˜λ₯Ό ν‘œμ‹œν•˜κΈ° μœ„ν•΄μ„œλŠ” (i % m) 처럼 μƒμœ„ μ°¨μ›μ˜ 값은 λͺ¨λ“ˆλŸ¬ 연산을 μ²˜λ¦¬ν•΄μ•Όκ² μ§€λ§Œ 이번 λ¬Έμ œμ—μ„œλŠ” ꡳ이 μ •ν™•ν•œ μœ„μΉ˜ 값은 ν•„μš” μ—†μœΌλ‹ˆ λ¬΄μ‹œν–ˆμŠ΅λ‹ˆλ‹€.

각 μ°¨μ›λ³„λ‘œ μœ„, μ•„λž˜μ˜ 값은 ν•΄λ‹Ή μ°¨μ›μ˜ 크기만큼 λ”ν•˜κ³  λΉΌλ©΄ λ©λ‹ˆλ‹€. 말둜 μ„€λͺ…ν•˜κΈ° νž˜λ“œλ„€μš”. 3μ°¨μ›μ˜ λ°°μ—΄ arr[i][j][k]κ°€ μžˆμ„ λ•Œ, i 값이 1 증가/κ°μ†Œν•˜λ©΄ arr의 1차원 λ°°μ—΄ μƒμ—μ„œ j * k 만큼 μΆ”κ°€/κ°μ†Œ λ©λ‹ˆλ‹€. j 값이 1 증가/κ°μ†Œν•˜λ©΄ 1차원 λ°°μ—΄ μƒμ—μ„œ k 만큼 μΆ”κ°€/κ°μ†Œ λ©λ‹ˆλ‹€.

λ”°λΌμ„œ 각 차원별 μœ„ μ•„λž˜μ— μ•ˆμ΅μ€ ν† λ§ˆν† κ°€ μžˆλŠ”μ§€λ§Œ νƒμƒ‰ν–ˆμŠ΅λ‹ˆλ‹€. λ‚˜λ¨Έμ§„ κΈ°μ‘΄ ν† λ§ˆν†  λ¬Έμ œλž‘ 같은 μ›λ¦¬λ‘œ ν•΄κ²°ν–ˆμŠ΅λ‹ˆλ‹€!

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

@yuyu0830 yuyu0830 self-assigned this Mar 20, 2024
@yuyu0830 yuyu0830 changed the title 2 yuyu0830 3-yuyu0830 Mar 20, 2024
@yuyu0830 yuyu0830 closed this Mar 20, 2024
@yuyu0830 yuyu0830 deleted the 2-yuyu0830 branch March 20, 2024 06:10
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