Skip to content

Commit

Permalink
#9- 1463 문제 풀이 1차 시도
Browse files Browse the repository at this point in the history
  • Loading branch information
6uohul committed Sep 17, 2023
1 parent 3bc34b5 commit d2f829f
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 14 deletions.
10 changes: 6 additions & 4 deletions Algorithm/Algorithm.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
objects = {

/* Begin PBXBuildFile section */
1407E1402AB7121A00B4B4E6 /* main.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1407E13F2AB7121A00B4B4E6 /* main.swift */; };
1407E1422AB715CA00B4B4E6 /* main.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1407E1412AB715CA00B4B4E6 /* main.swift */; };
/* End PBXBuildFile section */

/* Begin PBXCopyFilesBuildPhase section */
Expand All @@ -27,7 +27,8 @@
1407E10F2AAC384100B4B4E6 /* 2588.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = 2588.swift; sourceTree = "<group>"; };
1407E13B2AAE02CC00B4B4E6 /* 1152.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = 1152.swift; sourceTree = "<group>"; };
1407E13D2AB70A9600B4B4E6 /* 2163.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = 2163.swift; sourceTree = "<group>"; };
1407E13F2AB7121A00B4B4E6 /* main.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = main.swift; sourceTree = "<group>"; };
1407E13F2AB7121A00B4B4E6 /* 2751.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = 2751.swift; sourceTree = "<group>"; };
1407E1412AB715CA00B4B4E6 /* main.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = main.swift; sourceTree = "<group>"; };
147A87B62AA07AF300C5FEFB /* Algorithm */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = Algorithm; sourceTree = BUILT_PRODUCTS_DIR; };
147A87B92AA07AF300C5FEFB /* 정수형_입력받기.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "정수형_입력받기.swift"; sourceTree = "<group>"; };
147A87C22AA0820E00C5FEFB /* 개행_단위_입력받기.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "개행_단위_입력받기.swift"; sourceTree = "<group>"; };
Expand Down Expand Up @@ -89,7 +90,8 @@
1407E10F2AAC384100B4B4E6 /* 2588.swift */,
1407E13B2AAE02CC00B4B4E6 /* 1152.swift */,
1407E13D2AB70A9600B4B4E6 /* 2163.swift */,
1407E13F2AB7121A00B4B4E6 /* main.swift */,
1407E13F2AB7121A00B4B4E6 /* 2751.swift */,
1407E1412AB715CA00B4B4E6 /* main.swift */,
);
path = BOJ;
sourceTree = "<group>";
Expand Down Expand Up @@ -153,7 +155,7 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
1407E1402AB7121A00B4B4E6 /* main.swift in Sources */,
1407E1422AB715CA00B4B4E6 /* main.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down
21 changes: 21 additions & 0 deletions Algorithm/Algorithm/BOJ/2751.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
//
// 2751.swift
// 수 정렬하기 2
//
// Created by 김인영 on 2023/09/17.
//

import Foundation

let n = Int(readLine()!)!
var array = [Int]()

for i in 0...n-1 {
array.append(Int(readLine()!)!)
}

array.sort()

for i in 0...n-1 {
print(array[i])
}
27 changes: 17 additions & 10 deletions Algorithm/Algorithm/BOJ/main.swift
Original file line number Diff line number Diff line change
@@ -1,21 +1,28 @@
//
// 2751.swift
// 수 정렬하기 2
// 1463.swift
// 1로 만들기
//
// Created by 김인영 on 2023/09/17.
//

import Foundation

let n = Int(readLine()!)!
var array = [Int]()
var input = Int(readLine()!)!
var count = 0

for i in 0...n-1 {
array.append(Int(readLine()!)!)
func caculate(_ input: Int) -> Int {
if input % 3 == 0 {
return input / 3
} else if input % 2 == 0 {
return input / 2
} else {
return input - 1
}
}

array.sort()

for i in 0...n-1 {
print(array[i])
while input != 1 {
input = caculate(input)
count += 1
}

print(count)

0 comments on commit d2f829f

Please sign in to comment.