Potato
์•ˆ๋…•ํ•˜์„ธ์š”, ๊ฐ์žก๋‹ˆ๋‹ค?๐Ÿฅ” ^___^ ๐Ÿ˜บ github ๋ฐ”๋กœ๊ฐ€๊ธฐ ๐Ÿ‘‰๐Ÿป

Algorithm/Baekjoon

[๋ฐฑ์ค€] (Swift) 10824๋ฒˆ - ๋„ค ์ˆ˜

๊ฐ์ž ๐Ÿฅ” 2022. 2. 18. 21:33
๋ฐ˜์‘ํ˜•

๋ฌธ์ œ ๋งํฌ

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

 

10824๋ฒˆ: ๋„ค ์ˆ˜

์ฒซ์งธ ์ค„์— ๋„ค ์ž์—ฐ์ˆ˜ A, B, C, D๊ฐ€ ์ฃผ์–ด์ง„๋‹ค. (1 ≤ A, B, C, D ≤ 1,000,000)

www.acmicpc.net

 

๋‚ด๊ฐ€ ํ‘ผ ํ’€์ด

  • ์–ด์ฐจํ”ผ ๋ฌธ์ œ์—์„œ 4๊ฐœ์˜ ์ˆ˜ ๋งŒ ์ฃผ์–ด์งˆ ๊ฒƒ์ด๊ธฐ ๋•Œ๋ฌธ์— ์ธ๋ฑ์Šค๋กœ 0,1 ๋ฒˆ์ด๋ฉด answer1์— ์ €์žฅ
  • ์ธ๋ฑ์Šค 2,3 ์ด๋ฉด answer2์— ์ €์žฅ
  • answer1, answer2 ๋Š” ์•ž+๋’ค ๋ฌธ์ž๊ฐ€ ํ•ฉ์ณ์ ธ์•ผํ•˜๊ธฐ ๋•Œ๋ฌธ์— String์œผ๋กœ ์ฒ˜๋ฆฌ
  • printํ• ๋•Œ int๋กœ ๋ฐ”๊ฟ”์„œ ์ถœ๋ ฅ
let line = readLine()!.split(separator: " ").map{ String($0) }
var answer1 = ""
var answer2 = ""

for i in 0..<line.count {
    if i == 0 || i == 1 {
        answer1 += line[i]
    }else {
        answer2 += line[i]
    }
}

print(Int(answer1)! + Int(answer2)!)
๋ฐ˜์‘ํ˜•