-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* [1주차] : 홍범순 - 16503 괄호 없는 사칙연산 Bronze3 (#44) * [1주차] : 홍범순 - 1699 제곱수의 합 Silver2 (#44) * [1주차] : 홍범순 - 5639 이진 검색 트리 Gold5 (#44) * [2주차] : 홍범순 - 1225 이상한 곱셈 Bronze2 (#48) * [2주차] : 홍범순 - 11478 서로 다른 부분 문자열의 개수 Silver3(#48) * [1주차] : 홍범순 - 16503 괄호 없는 사칙연산 Bronze3 (#44) * [1주차] : 홍범순 - 1699 제곱수의 합 Silver2 (#44) * [1주차] : 홍범순 - 5639 이진 검색 트리 Gold5 (#44) * [2주차] : 홍범순 - 1225 이상한 곱셈 Bronze2 (#48) * [2주차] : 홍범순 - 11478 서로 다른 부분 문자열의 개수 Silver3(#48) * [2주차] : 홍범순 - 10830 행렬 제곱 Gold4 (#48) * [3주차] : 홍범순 - 5883 아이폰 9S Silver4 (#60) * [3주차] : 홍범순 - 18247 겨울왕국 티켓 예매 Bronze3 (#60) * [3주차] : 홍범순 - 4913 페르마의 크리스마스 정리 Gold4 (#60)
- Loading branch information
1 parent
a0e263d
commit 0fa91cf
Showing
9 changed files
with
411 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
package main | ||
|
||
import ( | ||
"fmt" | ||
) | ||
|
||
var N, B int | ||
var A, res [][]int | ||
|
||
func main() { | ||
fmt.Scanf("%d %d", &N, &B) | ||
|
||
A = make([][]int, N) | ||
res = make([][]int, N) | ||
|
||
for i := 0; i < N; i++ { | ||
A[i] = make([]int, N) | ||
res[i] = make([]int, N) | ||
for j := 0; j < N; j++ { | ||
fmt.Scan(&A[i][j]) | ||
} | ||
res[i][i] = 1 | ||
} | ||
|
||
for B > 0 { | ||
if B%2 == 1 { | ||
res = matrixMulti(res, A) | ||
} | ||
A = matrixMulti(A, A) | ||
B /= 2 | ||
} | ||
|
||
printMatrix() | ||
} | ||
|
||
func matrixMulti(A, B [][]int) [][]int { | ||
tmp := make([][]int, N) | ||
for i := 0; i < N; i++ { | ||
tmp[i] = make([]int, N) | ||
for j := 0; j < N; j++ { | ||
tmp[i][j] = 0 | ||
for k := 0; k < N; k++ { | ||
tmp[i][j] += (A[i][k] * B[k][j]) | ||
} | ||
tmp[i][j] = tmp[i][j] % 1000 | ||
} | ||
} | ||
return tmp | ||
} | ||
|
||
func printMatrix() { | ||
for i := 0; i < N; i++ { | ||
for j := 0; j < N; j++ { | ||
fmt.Printf("%d ", res[i][j]) | ||
} | ||
fmt.Println() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package main | ||
|
||
import ( | ||
"fmt" | ||
) | ||
|
||
func main() { | ||
var input string | ||
fmt.Scanf("%s", &input) | ||
|
||
data_array := make(map[string]bool) | ||
var substr string = "" | ||
|
||
for i := 0; i < len(input); i++ { | ||
for j := i; j < len(input); j++ { | ||
substr = input[i : j+1] | ||
data_array = add(data_array, substr) | ||
} | ||
} | ||
|
||
fmt.Println(len(data_array)) | ||
} | ||
|
||
func add(s map[string]bool, v string) map[string]bool { | ||
s[v] = true | ||
return s | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package main | ||
|
||
import ( | ||
"fmt" | ||
) | ||
|
||
func main() { | ||
var A, B string | ||
fmt.Scanf("%s %s", &A, &B) | ||
|
||
count := 0 | ||
|
||
for i := 0; i < len(A); i++ { | ||
for j := 0; j < len(B); j++ { | ||
count += int(A[i]-'0') * int(B[j]-'0') | ||
} | ||
} | ||
|
||
fmt.Println(count) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
package main | ||
|
||
import ( | ||
"bufio" | ||
"fmt" | ||
"os" | ||
"strconv" | ||
"strings" | ||
) | ||
|
||
func main() { | ||
in := bufio.NewReader(os.Stdin) | ||
data, _ := in.ReadString('\n') | ||
data = strings.TrimSpace(data) | ||
|
||
split := strings.Split(data, " ") | ||
|
||
Kstr := []string{split[0], split[2], split[4]} | ||
K := []int{} | ||
O := []string{split[1], split[3]} | ||
|
||
for _, v := range Kstr { | ||
j, _ := strconv.Atoi(v) | ||
K = append(K, j) | ||
} | ||
|
||
calc1 := calc(calc(K[0], K[1], O[0]), K[2], O[1]) | ||
calc2 := calc(K[0], calc(K[1], K[2], O[1]), O[0]) | ||
|
||
if calc1 <= calc2 { | ||
fmt.Println(calc1) | ||
fmt.Println(calc2) | ||
|
||
} else { | ||
fmt.Println(calc2) | ||
fmt.Println(calc1) | ||
} | ||
} | ||
|
||
func calc(a, b int, op string) int { | ||
|
||
switch op { | ||
case "+": | ||
return a + b | ||
case "-": | ||
return a - b | ||
case "*": | ||
return a * b | ||
case "/": | ||
return a / b | ||
} | ||
return 0 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package main | ||
|
||
import ( | ||
_ "bufio" | ||
"fmt" | ||
_ "os" | ||
_ "strconv" | ||
) | ||
|
||
func main() { | ||
var n int | ||
fmt.Scan(&n) | ||
|
||
var data [100010]int | ||
data[0] = 0 | ||
data[1] = 1 | ||
|
||
for i := 0; i <= n; i++ { | ||
data[i] = i | ||
} | ||
|
||
for i := 1; i <= n; i++ { | ||
for j := 1; j*j <= i; j++ { | ||
data[i] = min(data[i], data[i-j*j]+1) | ||
} | ||
} | ||
fmt.Println(data[n]) | ||
} | ||
|
||
func min(a, b int) int { | ||
if a < b { | ||
return a | ||
} | ||
return b | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package main | ||
|
||
import ( | ||
"fmt" | ||
) | ||
|
||
func main() { | ||
var T int | ||
fmt.Scan(&T) | ||
|
||
for ; T > 0; T-- { | ||
var N, M int | ||
fmt.Scan(&N, &M) | ||
|
||
//L : 12 | ||
|
||
if N < 12 || M < 4 { | ||
fmt.Print("-1\n") | ||
} else { | ||
fmt.Printf("%d\n", 11*M+4) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
package main | ||
|
||
import ( | ||
"fmt" | ||
) | ||
|
||
var ARR_SIZE int = 1000010 | ||
var prime [1000010]bool | ||
var primesum [1000010]int | ||
var squaresum [1000010]int | ||
|
||
func main() { | ||
Init() | ||
getPrimes() | ||
//debugprint() | ||
|
||
for i := 3; i < ARR_SIZE; i++ { | ||
if prime[i] == true { | ||
primesum[i] = primesum[i-1] + 1 | ||
} else { | ||
primesum[i] = primesum[i-1] | ||
} | ||
|
||
if prime[i] == true && (i%4) == 1 { | ||
squaresum[i] = squaresum[i-1] + 1 | ||
} else { | ||
squaresum[i] = squaresum[i-1] | ||
} | ||
} | ||
|
||
for { | ||
var L, U int | ||
fmt.Scan(&L, &U) | ||
|
||
x, y := 0, 0 | ||
|
||
if L == -1 && U == -1 { | ||
return | ||
} | ||
|
||
if L >= 1 { | ||
x = primesum[U] - primesum[L-1] | ||
y = squaresum[U] - squaresum[L-1] | ||
} else if L < 1 && U >= 0 { | ||
x = primesum[U] | ||
y = squaresum[U] | ||
} else { | ||
x = 0 | ||
y = 0 | ||
} | ||
|
||
fmt.Printf("%d %d %d %d\n", L, U, x, y) | ||
} | ||
|
||
} | ||
|
||
func Init() { | ||
for i := 2; i < ARR_SIZE; i++ { | ||
prime[i] = true | ||
primesum[i] = 0 | ||
squaresum[i] = 0 | ||
} | ||
primesum[2] = 1 | ||
squaresum[2] = 1 | ||
} | ||
|
||
func getPrimes() { | ||
prime[1] = false | ||
for i := 2; i*i < ARR_SIZE; i++ { | ||
if prime[i] == true { | ||
for j := i * i; j < ARR_SIZE; j += i { | ||
prime[j] = false | ||
} | ||
} | ||
} | ||
} | ||
|
||
func debugprint() { | ||
for i := 0; i < 50; i++ { | ||
fmt.Printf("%d %d \n", i, prime[i]) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
package main | ||
|
||
import ( | ||
"bufio" | ||
"fmt" | ||
"os" | ||
"strconv" | ||
"strings" | ||
) | ||
|
||
var arr [10010]int | ||
|
||
func main() { | ||
in := bufio.NewReader(os.Stdin) | ||
|
||
n := 0 | ||
for { | ||
data, _ := in.ReadString('\n') | ||
data = strings.TrimSpace(data) | ||
if data == "" { | ||
break | ||
} | ||
arr[n], _ = strconv.Atoi(data) | ||
n++ | ||
} | ||
|
||
searcher(0, n) | ||
|
||
} | ||
|
||
func searcher(start, end int) { | ||
if start >= end { | ||
return | ||
} | ||
|
||
var i int = start | ||
|
||
for ; i < end; i++ { | ||
if arr[start] < arr[i] { | ||
break | ||
} | ||
} | ||
|
||
searcher(start+1, i) | ||
searcher(i, end) | ||
|
||
fmt.Println(arr[start]) | ||
} |
Oops, something went wrong.