diff --git "a/cmkim/\354\202\274\354\204\261SDS_2021\355\225\230\352\263\204/test.py" "b/cmkim/\354\202\274\354\204\261SDS_2021\355\225\230\352\263\204/test.py" new file mode 100644 index 0000000..556c018 --- /dev/null +++ "b/cmkim/\354\202\274\354\204\261SDS_2021\355\225\230\352\263\204/test.py" @@ -0,0 +1,4 @@ +a = -100 +b = 5 + +print('a%b = ', a%b) \ No newline at end of file diff --git "a/cmkim/\354\202\274\354\204\261SDS_2021\355\225\230\352\263\204/\353\202\231\355\203\200 \354\230\256\352\270\260\352\270\260.py" "b/cmkim/\354\202\274\354\204\261SDS_2021\355\225\230\352\263\204/\353\202\231\355\203\200 \354\230\256\352\270\260\352\270\260.py" new file mode 100644 index 0000000..7f8d7b3 --- /dev/null +++ "b/cmkim/\354\202\274\354\204\261SDS_2021\355\225\230\352\263\204/\353\202\231\355\203\200 \354\230\256\352\270\260\352\270\260.py" @@ -0,0 +1,44 @@ +def main(): + t = int(input())#테스트케이스 개수 + + for i in range(t): + n = int(input())#낙타 마리수 + arr = list(map(int, input().split()))#낙타 이동시간 저장할 배열 + arr.sort() + count = len(arr) #낙타의 총 마리수 + + + answer = 0 + if count >= 4: + trans = arr[0] + arr[1] * 2 + + while count > 0: + + if count >= 4: + answer += (arr[count - 1] + trans) + count -= 2 + + elif count == 1: + answer += arr[0] + count -= 1 + + elif count == 2: + answer += arr[1] + count -= 2 + + elif count == 3: + answer += (arr[0] + arr[1] + arr[2]) + count -= 3 + + + + output = "#%d"%(i+1) + + + print(output, answer) + + + + + +main() \ No newline at end of file diff --git "a/cmkim/\354\202\274\354\204\261SDS_2021\355\225\230\352\263\204/\353\237\254\354\213\234\354\225\204\354\233\214.py" "b/cmkim/\354\202\274\354\204\261SDS_2021\355\225\230\352\263\204/\353\237\254\354\213\234\354\225\204\354\233\214.py" new file mode 100644 index 0000000..b9a2c48 --- /dev/null +++ "b/cmkim/\354\202\274\354\204\261SDS_2021\355\225\230\352\263\204/\353\237\254\354\213\234\354\225\204\354\233\214.py" @@ -0,0 +1,8 @@ +def main(): + # 이곳에 소스코드를 작성하세요. + # Python3 만 지원됩니다. + # pass는 삭제해도 됩니다. + pass + + +main() \ No newline at end of file diff --git "a/cmkim/\354\202\274\354\204\261SDS_2021\355\225\230\352\263\204/\354\236\220\353\254\274\354\207\240.py" "b/cmkim/\354\202\274\354\204\261SDS_2021\355\225\230\352\263\204/\354\236\220\353\254\274\354\207\240.py" new file mode 100644 index 0000000..ef0db0a --- /dev/null +++ "b/cmkim/\354\202\274\354\204\261SDS_2021\355\225\230\352\263\204/\354\236\220\353\254\274\354\207\240.py" @@ -0,0 +1,55 @@ +def main(): + + t = int(input()) + + for test in range(t): + + n, k = map(int, input().split()) #열 행 순서 + arr = [[0]*k for _ in range(n)] #같은 인덱스 안에서 움직이는게 쉬워서 가로세로 변경 + arr2= [[0]*k for _ in range(n)] #arr[i][j] = arr[i]행에서 arr[i][j]로 1을 옮기는 최소 횟수 + #arr[0~k][j] 값의 합의 최솟값구하기 + loc = [[] for _ in range(n)] + answer = [0]*k + result = n*k + #print(loc) + for i in range(k): + temp = input() + for j in range(len(temp)): + if temp[j] == '1': + arr[j][i] = 1 + loc[j].append((j, i)) + + # print(loc) + # for i in range(n): + # print(arr[i]) + + for i in range(n): + for j in range(k): + min_v = k + for p in range(len(loc[i])): + min_v = min(min_v, abs(loc[i][p][1] - j)) + min_v = min(min_v, (j+k) - loc[i][p][1]) + arr2[i][j] = min_v + + # print('') + # for i in range(n): + # print(arr2[i]) + + for i in range(n): + for j in range(k): + answer[j] += arr2[i][j] + + + # print('') + # for i in range(k): + # print(answer[i]) + + for i in range(k): + result = min(result, answer[i]) + + + + output = "#%d" % (test + 1) + + print(output, result) +main() \ No newline at end of file diff --git "a/cmkim/\354\202\274\354\204\261SDS_2021\355\225\230\352\263\204/\354\240\204\354\236\220\354\210\253\354\236\220\355\214\220.py" "b/cmkim/\354\202\274\354\204\261SDS_2021\355\225\230\352\263\204/\354\240\204\354\236\220\354\210\253\354\236\220\355\214\220.py" new file mode 100644 index 0000000..ca4c395 --- /dev/null +++ "b/cmkim/\354\202\274\354\204\261SDS_2021\355\225\230\352\263\204/\354\240\204\354\236\220\354\210\253\354\236\220\355\214\220.py" @@ -0,0 +1,95 @@ +from _collections import deque + +def main(): + + t = int(input()) + + for test in range(t): + a, b, l = map(int, input().split()) + arr = list(map(str, input())) + + key1 = 0 + for i in range(len(arr)): + if arr[i] == '+': + key1 += pow(10, i) + elif arr[i] == '-': + key1 -= pow(10, i) + + key2 = 0 + arr.reverse() + for i in range(len(arr)): + if arr[i] == '+': + key2 += pow(10, i) + elif arr[i] == '-': + key2 -= pow(10, i) + + key1, key2 = key2, key1 + + print('') + print('#case', test+1) + print('key1, key2 = ', key1, key2) + print('b-a = ', b-a) + + #raw값 구하는것부터 오류임 + if (b-a) % key1 == 0: + raw1 = abs((a-b)//key1) + + elif (b-a) % key2 == 0: + raw1 = abs((a-b)//key2) + + else: + raw1 = -1 + answer = -1 + + #print('raw1 = ', raw1) + + if raw1 > 0: + count = len(str(raw1))#raw1의 자리수 + raw2 = pow(10, count) - raw1 + temp1, temp2 = 0, 1 + + for i in range(count): + temp1 += raw1 % 10 + temp2 += raw2 % 10 + raw1 = raw1 // 10 + raw2 = raw2 // 10 + + print('temp1, temp2 = ', temp1, temp2) + + answer = min(temp1, temp2) + # if not key1 * -1 == key2: + # answer = temp1 + + output = "#%d" % (test + 1) + print(output, answer) + +def bfs(a, av, b, bv, target): + arr_a = [] + arr_b = [] + while a < 1e6: + arr_a.append(a) + a *= 10 + while b < 1e6: + arr_b.append(b) + b *= 10 + + # print(arr_a) + # print(arr_b) + + + +#main() + +''' +5 +159 555 2 ++- +1142 350 3 ++0- +116 676 2 ++- +887 854 2 +0- +370 994 2 ++0 +''' \ No newline at end of file