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 #13

Merged
merged 1 commit into from
Mar 23, 2024
Merged

3-yuyu0830 #13

merged 1 commit into from
Mar 23, 2024

Conversation

yuyu0830
Copy link
Collaborator

@yuyu0830 yuyu0830 commented Mar 20, 2024

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

๏ฟฝํ•˜์ดํผ ํ† ๋งˆํ† 

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

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 ๋งŒํผ ์ถ”๊ฐ€/๊ฐ์†Œ ๋ฉ๋‹ˆ๋‹ค.

๋”ฐ๋ผ์„œ ๊ฐ ์ฐจ์›๋ณ„ ์œ„ ์•„๋ž˜์— ์•ˆ์ต์€ ํ† ๋งˆํ† ๊ฐ€ ์žˆ๋Š”์ง€๋งŒ ํƒ์ƒ‰ํ–ˆ์Šต๋‹ˆ๋‹ค. ๋‚˜๋จธ์ง„ ๊ธฐ์กด ํ† ๋งˆํ†  ๋ฌธ์ œ๋ž‘ ๊ฐ™์€ ์›๋ฆฌ๋กœ ํ•ด๊ฒฐํ–ˆ์Šต๋‹ˆ๋‹ค!

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

Copy link
Collaborator

@InSange InSange left a comment

Choose a reason for hiding this comment

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

์ฐธ๊ณ  ๊ธ€
ํ•ด๋‹น ๊ธ€์„ ๋งŽ์ด ์ฐธ๊ณ ํ•˜๋ฉด์„œ ์ดํ•ดํ–ˆ์Šต๋‹ˆ๋‹ค..!
๋‹ค์ฐจ์›์„ ํ•˜๋‚˜์˜ ์ฐจ์›์œผ๋กœ ํ‘œ๊ธฐํ•˜๊ธฐ ์œ„ํ•ด์„œ ๋ฌธ์ œ ์ œ์ž‘์ž๊ฐ€ ์˜๋„์ ์œผ๋กœ 10^6๊นŒ์ง€ ์ œํ•œ์„ ๋’€๊ตฐ์š”. ํ•˜์ง€๋งŒ ์ผ์ฐจ์›์œผ๋กœ ๋‚˜๋ˆˆ ๋งŒํผ ๋‹ค๋ฅธ ์ฐจ์›์˜ ๋ณ€์— ์ ‘๊ทผํ•˜๊ธฐ ์œ„ํ•ด์„œ ๊ณ„์‚ฐ ์ˆ˜์‹๊นŒ์ง€ ๋ฐœ๊ฒฌํ•˜๊ธฐ๊นŒ์ง€๊ฐ€ ๋งค์šฐ ์–ด๋ ค์šด ๋ถ€๋ถ„์ด์—ˆ๋˜ ๊ฒƒ ๊ฐ™์Šต๋‹ˆ๋‹ค..!
์ˆ ์ฝ”๋”ฉ์€ ๊ทธ๋ ‡๋‹ค์ณ๋„ ์ •๋ง ๋ณ€ํƒœ์ ์ธ ๋ฌธ์ œ๋„ค์š”... ๋ฒฝ์„ ๋Š๋ผ๊ณ  ๊ฐ‘๋‹ˆ๋‹ค.

Copy link
Collaborator

@seongwon030 seongwon030 left a comment

Choose a reason for hiding this comment

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

์ œ๊ฐ€ ํ’€์–ด๋ณผ ๋ฌธ์ œ๊ฐ€ ์ƒ๊ฒผ๋„ค์š” ! 11์ค‘ for๋ฌธ์œผ๋กœ ํ’€๋‹ค๊ฐ€ ์ •์‹ ๋‚˜๊ฐˆ์ˆ˜๋„ ์žˆ๊ฒ ๋‹ค๋Š” ์ƒ๊ฐ์ด..

Copy link
Contributor

@dhlee777 dhlee777 left a comment

Choose a reason for hiding this comment

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

2์ฐจ์›๋ฐฐ์—ด ๊ฐ’์„ ์ฒ˜๋ฆฌํ• ๋•Œ for๋ฌธ์„ 2๋ฒˆ ์•ˆ์“ฐ๊ณ  /,% ์—ฐ์‚ฐ์ž๋ฅผ์ด์šฉํ•ด์„œ 1๋ฒˆ์œผ๋กœ ์ฒ˜๋ฆฌํ•  ์ˆ˜ ๋„ ์žˆ์—ˆ๊ตฐ์š”.. ์ €๋„ ๋‹ค์Œ์— ์ด๋Ÿฐ๋ฐฉ๋ฒ•์„ ์‚ฌ์šฉํ•ด๋ด์•ผ๊ฒ ์Šต๋‹ˆ๋‹ค.

@yuyu0830
Copy link
Collaborator Author

์ œ๊ฐ€ ํ’€์–ด๋ณผ ๋ฌธ์ œ๊ฐ€ ์ƒ๊ฒผ๋„ค์š” ! 11์ค‘ for๋ฌธ์œผ๋กœ ํ’€๋‹ค๊ฐ€ ์ •์‹ ๋‚˜๊ฐˆ์ˆ˜๋„ ์žˆ๊ฒ ๋‹ค๋Š” ์ƒ๊ฐ์ด..

๊ถ๊ธˆํ•˜๋„ค์š”.. ๋ˆ„๊ตฐ๊ฐ€๋Š” ๊ผญ 11์ค‘ for๋ฌธ์œผ๋กœ ํ’€์–ด๋ด์ฃผ๊ธธ..

@yuyu0830 yuyu0830 merged commit b4d7716 into main Mar 23, 2024
1 check passed
@yuyu0830 yuyu0830 deleted the 3-yuyu0830 branch March 23, 2024 09:22
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.

5 participants