From 21b50e9c8aff589d6a2d9b3badd1fe8333308459 Mon Sep 17 00:00:00 2001 From: Suanna01 Date: Thu, 6 Apr 2023 14:16:06 +0900 Subject: [PATCH 01/80] =?UTF-8?q?#2=20:=2015649=5FN=EA=B3=BCM(1)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../15649_N\352\263\274M(1).py" | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 "\354\235\264\353\213\210\354\204\261\354\233\220/15649_N\352\263\274M(1).py" diff --git "a/\354\235\264\353\213\210\354\204\261\354\233\220/15649_N\352\263\274M(1).py" "b/\354\235\264\353\213\210\354\204\261\354\233\220/15649_N\352\263\274M(1).py" new file mode 100644 index 0000000..beb2005 --- /dev/null +++ "b/\354\235\264\353\213\210\354\204\261\354\233\220/15649_N\352\263\274M(1).py" @@ -0,0 +1,13 @@ +import sys +import itertools +n,m=map(int,sys.stdin.readline().split()) #map(적용시킬 함수, 적용할 값들) : 입력받은 값을 정수타입으로 변환 +nums=[i for i in range(1,n+1)] #i = 1 ~ n + +arr=itertools.permutations(nums, m) #permutations(iterable, r) : iterable에서 원소개수가 r개인 순열 뽑기 +# print(list(arr)) + +for i in arr: + for j in i: + print(j,end=" ") + print() + From ae9f427c9396720edaca86f577b671bd1b9b8e67 Mon Sep 17 00:00:00 2001 From: plum-king Date: Thu, 6 Apr 2023 14:16:51 +0900 Subject: [PATCH 02/80] =?UTF-8?q?#2=20:=2015649=5FN=EA=B3=BC=20M(1)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../15649_N\352\263\274M(1).py" | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 "\354\235\264\353\213\210\354\247\200\354\210\230/15649_N\352\263\274M(1).py" diff --git "a/\354\235\264\353\213\210\354\247\200\354\210\230/15649_N\352\263\274M(1).py" "b/\354\235\264\353\213\210\354\247\200\354\210\230/15649_N\352\263\274M(1).py" new file mode 100644 index 0000000..8e61cbe --- /dev/null +++ "b/\354\235\264\353\213\210\354\247\200\354\210\230/15649_N\352\263\274M(1).py" @@ -0,0 +1,6 @@ +from itertools import permutations +n, m = map(int, input().split()) +arr = list(range(1, n+1)) +num = list(permutations(arr, m)) +for i in num: + print(' '.join(map(str,i))) \ No newline at end of file From e8cb0baf6b776edda2e16eb95f06a08b23ad52ab Mon Sep 17 00:00:00 2001 From: leejw-lu Date: Thu, 6 Apr 2023 14:23:51 +0900 Subject: [PATCH 03/80] =?UTF-8?q?#2=20:=2015649=5FN=EA=B3=BC=20M(1)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../15649_N\352\263\274 M(1).py" | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 "\354\235\264\353\213\210\354\247\200\354\232\260/15649_N\352\263\274 M(1).py" diff --git "a/\354\235\264\353\213\210\354\247\200\354\232\260/15649_N\352\263\274 M(1).py" "b/\354\235\264\353\213\210\354\247\200\354\232\260/15649_N\352\263\274 M(1).py" new file mode 100644 index 0000000..95ed01b --- /dev/null +++ "b/\354\235\264\353\213\210\354\247\200\354\232\260/15649_N\352\263\274 M(1).py" @@ -0,0 +1,16 @@ +import itertools + +n, m = map(int, input().split()) +nums = [i for i in range(1, n+1)] +#[1,2,3,4] + +p_array = itertools.permutations(nums, m) +#[(1, 2), (1, 3), (1, 4), (2, 1), (2, 3), (2, 4), (3, 1), (3, 2), (3, 4), (4, 1), (4, 2), (4, 3)] + +#(4, 3) +for i in p_array: + for j in i: + print(j, end = ' ') #4 3 + print() + + From 62699e43e909d42b32af8ef83749e618ff6cf108 Mon Sep 17 00:00:00 2001 From: yjhss <20211420.sungshin.ac.kr> Date: Thu, 6 Apr 2023 14:26:51 +0900 Subject: [PATCH 04/80] =?UTF-8?q?#2=20:=2015649=5FN=EA=B3=BC=20M(1)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../15649_N\352\263\274 M(1).py" | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 "\354\235\264\355\213\260\354\234\240\354\247\204/15649_N\352\263\274 M(1).py" diff --git "a/\354\235\264\355\213\260\354\234\240\354\247\204/15649_N\352\263\274 M(1).py" "b/\354\235\264\355\213\260\354\234\240\354\247\204/15649_N\352\263\274 M(1).py" new file mode 100644 index 0000000..9621a29 --- /dev/null +++ "b/\354\235\264\355\213\260\354\234\240\354\247\204/15649_N\352\263\274 M(1).py" @@ -0,0 +1,18 @@ +import itertools +#from itertools import permutations + +n,m = map(int, input().split()) + +a = [] +for i in range(1,n+1): + a.append(i) + +pe = itertools.permutations(a,m) + +#print("hello",end='') +#print(*list(pe)) + +for i in pe: + for j in i: + print(j,end = ' ') + print() \ No newline at end of file From ce8ab7967bdb0bc481484fe603fa380719156461 Mon Sep 17 00:00:00 2001 From: Jiyun Kim Date: Thu, 6 Apr 2023 14:27:06 +0900 Subject: [PATCH 05/80] =?UTF-8?q?#2:=2015649=5FN=EA=B3=BC=20M(1)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../15649_N\352\263\274 M(1).py" | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 "\354\235\264\355\213\260\354\247\200\354\234\244/15649_N\352\263\274 M(1).py" diff --git "a/\354\235\264\355\213\260\354\247\200\354\234\244/15649_N\352\263\274 M(1).py" "b/\354\235\264\355\213\260\354\247\200\354\234\244/15649_N\352\263\274 M(1).py" new file mode 100644 index 0000000..b2d3e62 --- /dev/null +++ "b/\354\235\264\355\213\260\354\247\200\354\234\244/15649_N\352\263\274 M(1).py" @@ -0,0 +1,24 @@ +#itertools의 permutations 함수를 사용해서 풀어보자. +#permutations(iterable, r) : iterable에서 원소 개수가 r개인 +#순열을 뽑는 것 + +import itertools +#from itertools import permutations + +n, m = map(int, input().split()) # 1부터 n까지 수 안에서 요소가 m개인 순열 만들기 +#nums [ i for i in range(1, n+1)] + +arr = [] +for i in range(n+1): + arr.append(i); +#[1,2,3,4] + + +pe = itertools.permutations(arr,m) #12게 +#[(1,2), (1,3), (1, 4)] + +for i in pe: #12개만큼 반복 + for j in i: + print(j, end=' ') # 1 2 + print() + From d92479d25bea2e2287f6b662327eff190bcc1ec0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=95=88=EC=98=88=EC=9B=90?= <78153914+yewonahn@users.noreply.github.com> Date: Thu, 6 Apr 2023 14:47:12 +0900 Subject: [PATCH 06/80] =?UTF-8?q?#2=20:=2015649=5FN=EA=B3=BCM(1)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../15649_N\352\263\274M(1).py" | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 "\354\235\264\355\213\260\354\230\210\354\233\220/15649_N\352\263\274M(1).py" diff --git "a/\354\235\264\355\213\260\354\230\210\354\233\220/15649_N\352\263\274M(1).py" "b/\354\235\264\355\213\260\354\230\210\354\233\220/15649_N\352\263\274M(1).py" new file mode 100644 index 0000000..52e4bab --- /dev/null +++ "b/\354\235\264\355\213\260\354\230\210\354\233\220/15649_N\352\263\274M(1).py" @@ -0,0 +1,13 @@ +from itertools import permutations +import sys + +print("1부터 N까지 자연수 중에서 중복 없이 M개 선택") + +n, m = map(int, input().split()) +nums = [i for i in range(1, n+1)] + +p_array = permutations(nums, m) +for i in p_array: + for j in i: + print(j, end = " ") + print() From b7ce4231c2e3347b2195c7746d60c18e942f5737 Mon Sep 17 00:00:00 2001 From: Seong Joon Hee Date: Sun, 9 Apr 2023 00:15:18 +0900 Subject: [PATCH 07/80] =?UTF-8?q?#2=20:=2015649=5FN=EA=B3=BC=20M(1)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../15649_N\352\263\274 M(1).py" | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 "\354\235\264\355\213\260\354\244\200\355\235\254/15649_N\352\263\274 M(1).py" diff --git "a/\354\235\264\355\213\260\354\244\200\355\235\254/15649_N\352\263\274 M(1).py" "b/\354\235\264\355\213\260\354\244\200\355\235\254/15649_N\352\263\274 M(1).py" new file mode 100644 index 0000000..657397f --- /dev/null +++ "b/\354\235\264\355\213\260\354\244\200\355\235\254/15649_N\352\263\274 M(1).py" @@ -0,0 +1,25 @@ +#2023-04-06-Week1 +#15649_N과 M(1) + +#itertools의 permutations 함수를 사용해서 풀어보자 +#permutations(iterable, r) : iterable에서 원소 개수가 r개인 순열을 뽑는 것 + +import itertools +import sys +#from itertools import permutations -> 함수 사용시 도트연산자 앞부분 생략 가능 + +n, m = map(int, input().split()) + +nums = [i for i in range(1, n+1)] + +nums = [] +for i in range(1, n+1) : + nums.append(i) + +arr = itertools.permutations(nums, m) + + +for i in arr : #리스트 원소 개수 -> set이 하나 + for j in i : + print(j, end=' ') + print() \ No newline at end of file From d7053ee4601d6209ed3c87fd1e7f6dbf6bcfab5a Mon Sep 17 00:00:00 2001 From: Seong Joon Hee Date: Sun, 9 Apr 2023 01:11:00 +0900 Subject: [PATCH 08/80] =?UTF-8?q?#2=20:=201978=5F=EC=86=8C=EC=88=98=20?= =?UTF-8?q?=EC=B0=BE=EA=B8=B0.py?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...4\354\210\230 \354\260\276\352\270\260.py" | 40 +++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 "\354\235\264\355\213\260\354\244\200\355\235\254/1978_\354\206\214\354\210\230 \354\260\276\352\270\260.py" diff --git "a/\354\235\264\355\213\260\354\244\200\355\235\254/1978_\354\206\214\354\210\230 \354\260\276\352\270\260.py" "b/\354\235\264\355\213\260\354\244\200\355\235\254/1978_\354\206\214\354\210\230 \354\260\276\352\270\260.py" new file mode 100644 index 0000000..95a8e84 --- /dev/null +++ "b/\354\235\264\355\213\260\354\244\200\355\235\254/1978_\354\206\214\354\210\230 \354\260\276\352\270\260.py" @@ -0,0 +1,40 @@ +#2023-04-08-Week1-과제 +#1978_소수 찾기 + +''' +입력 1 - 수의 개수 N < 100 +입력 2 - 1000 이하의 자연수 N개 +결과 - 입력2의 자연수 중 소수의 개수 출력 +''' + +#입력 받는 값 여러 개 -> map 함수 + + +n = int(input("입력 : \n")) + +num = list(map (int, input().split())) # 자료형, 함수 (.split() 공백으로 구분) + +result = 0 # 입력한 자연수 중 소수의 개수 + +for i in num : # 입력 받은 수들을 소수 확인 대상 i로 설정 + cnt = 0 # 소수 확인 대상의 약수 개수 + if i == 1 : # 1은 소수 아님 + continue + + for j in range (2, i+1) : # 2~i까지 + if (i%j == 0) : # 소수 확인 대상이 2부터 자기 자신으로 나눴을 때 0 이 되면 + cnt += 1 # 약수 개수 증가 + + if cnt == 1 : # 약수의 개수 1개 + result += 1 # 소수 개수 추가 + +print ("출력 : ", result) # 출력 : 입력 자연수 중 소수의 개수 + + + + + + + + + From e734ce3d193ba84241bfdaceb1d0a23eeddb4469 Mon Sep 17 00:00:00 2001 From: Seong Joon Hee Date: Sun, 9 Apr 2023 01:14:00 +0900 Subject: [PATCH 09/80] =?UTF-8?q?#2=20:=201978=5F=EC=86=8C=EC=88=98=20?= =?UTF-8?q?=EC=B0=BE=EA=B8=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...978_\354\206\214\354\210\230 \354\260\276\352\270\260.py" | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git "a/\354\235\264\355\213\260\354\244\200\355\235\254/1978_\354\206\214\354\210\230 \354\260\276\352\270\260.py" "b/\354\235\264\355\213\260\354\244\200\355\235\254/1978_\354\206\214\354\210\230 \354\260\276\352\270\260.py" index 95a8e84..621245a 100644 --- "a/\354\235\264\355\213\260\354\244\200\355\235\254/1978_\354\206\214\354\210\230 \354\260\276\352\270\260.py" +++ "b/\354\235\264\355\213\260\354\244\200\355\235\254/1978_\354\206\214\354\210\230 \354\260\276\352\270\260.py" @@ -7,12 +7,9 @@ 결과 - 입력2의 자연수 중 소수의 개수 출력 ''' -#입력 받는 값 여러 개 -> map 함수 - - n = int(input("입력 : \n")) -num = list(map (int, input().split())) # 자료형, 함수 (.split() 공백으로 구분) +num = list(map (int, input().split())) # 입력 받는 값 여러 개 -> map 함수 : 자료형, 함수 (.split() 공백으로 구분) result = 0 # 입력한 자연수 중 소수의 개수 From c25fd5df5e8bf95ea27665072f128eb6ca3498bb Mon Sep 17 00:00:00 2001 From: plum-king Date: Tue, 11 Apr 2023 23:56:42 +0900 Subject: [PATCH 10/80] =?UTF-8?q?#2=20:=201978=5F=EC=86=8C=EC=88=98=20?= =?UTF-8?q?=EC=B0=BE=EA=B8=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...6\214\354\210\230 \354\260\276\352\270\260.py" | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 "\354\235\264\353\213\210\354\247\200\354\210\230/1978_\354\206\214\354\210\230 \354\260\276\352\270\260.py" diff --git "a/\354\235\264\353\213\210\354\247\200\354\210\230/1978_\354\206\214\354\210\230 \354\260\276\352\270\260.py" "b/\354\235\264\353\213\210\354\247\200\354\210\230/1978_\354\206\214\354\210\230 \354\260\276\352\270\260.py" new file mode 100644 index 0000000..262b50b --- /dev/null +++ "b/\354\235\264\353\213\210\354\247\200\354\210\230/1978_\354\206\214\354\210\230 \354\260\276\352\270\260.py" @@ -0,0 +1,15 @@ +n = int(input()) +num = map(int, input().split()) + +sum = 0 +for i in num: + zeroNum = 0 + if i == 1: + zeroNum +=1 + else: + for j in range(2, int(i)): + if i % j == 0: + zeroNum+=1 + if zeroNum == 0: + sum+=1 +print(sum) \ No newline at end of file From 8b87499ede50a59a25b83b3c0f2980f3acfd0de7 Mon Sep 17 00:00:00 2001 From: Seong Joon Hee Date: Wed, 12 Apr 2023 12:53:12 +0900 Subject: [PATCH 11/80] =?UTF-8?q?#2=20:=2015650=5FN=EA=B3=BC=20M(2)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../15650_N\352\263\274 M(2).py" | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 "\354\235\264\355\213\260\354\244\200\355\235\254/15650_N\352\263\274 M(2).py" diff --git "a/\354\235\264\355\213\260\354\244\200\355\235\254/15650_N\352\263\274 M(2).py" "b/\354\235\264\355\213\260\354\244\200\355\235\254/15650_N\352\263\274 M(2).py" new file mode 100644 index 0000000..1c1ad5f --- /dev/null +++ "b/\354\235\264\355\213\260\354\244\200\355\235\254/15650_N\352\263\274 M(2).py" @@ -0,0 +1,29 @@ +#2023-04-08-Week1-과제 +#15650_N과 M(2) + +''' +자연수 N과 M이 주어졌을 때, 아래 조건을 만족하는 길이가 M인 수열을 모두 구하는 프로그램을 작성하시오. + +1부터 N까지 자연수 중에서 중복 없이 M개를 고른 수열 +고른 수열은 오름차순이어야 한다. + +입력 : 첫째 줄에 자연수 N과 M이 주어진다. (1 ≤ M ≤ N ≤ 8) +출력 : 한 줄에 하나씩 문제의 조건을 만족하는 수열을 출력한다. 중복되는 수열을 여러 번 출력하면 안되며, 각 수열은 공백으로 구분해서 출력해야 한다. + +수열은 사전 순으로 증가하는 순서로 출력해야 한다. + +''' +import itertools + +n,m = map(int,input().split()) + +num = itertools.combinations([i for i in range(1,n+1)],m) + +for i in num : + j = itertools.permutations(i) #permutation 가능한 모든 순열 + for k in j : + if k == sorted(k) : #오름차순으로 정렬된 경우면 출력 + print(" ".join(map(str, k))) + #map k의 요소들을 문자열로 반환 + #join 리스트 요소를 문자열로 연결 + #" "로 요소 사이에 구분자 \ No newline at end of file From 983db0d7a47aad7905a3d03780f4adefc3b2d663 Mon Sep 17 00:00:00 2001 From: Jiyun Kim Date: Wed, 12 Apr 2023 16:18:23 +0900 Subject: [PATCH 12/80] =?UTF-8?q?#2=20:=201978=5F=EC=86=8C=EC=88=98=20?= =?UTF-8?q?=EC=B0=BE=EA=B8=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...4\354\210\230 \354\260\276\352\270\260.py" | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 "\354\235\264\355\213\260\354\247\200\354\234\244/1978_\354\206\214\354\210\230 \354\260\276\352\270\260.py" diff --git "a/\354\235\264\355\213\260\354\247\200\354\234\244/1978_\354\206\214\354\210\230 \354\260\276\352\270\260.py" "b/\354\235\264\355\213\260\354\247\200\354\234\244/1978_\354\206\214\354\210\230 \354\260\276\352\270\260.py" new file mode 100644 index 0000000..4aefe48 --- /dev/null +++ "b/\354\235\264\355\213\260\354\247\200\354\234\244/1978_\354\206\214\354\210\230 \354\260\276\352\270\260.py" @@ -0,0 +1,19 @@ +### 소수의 개수 찾기 +n = int(input()) # 입력받을 숫자 갯수 + +nums = list(map(int, input().split())) # 공백으로 숫자 구분 +# 입력받은 n개의 숫자 ex: [1, 3, 5, 7] + +prime_cnt=0 #소수 갯수 +isPrime = True #소수 여부 + +for i in nums: + if i == 1: + continue + for j in range(2, i): # nums에 있는 숫자 i를 2부터 i-1까지 나눔 + if i % j == 0: # 나누어떨어지면 + isPrime = False # 소수 아님 + if isPrime == True: # 소수이면 + prime_cnt += 1 # 소수 갯수+1 +print(prime_cnt) + From ddf1e640aeeb1711843a69aea9b41e29b4fe9099 Mon Sep 17 00:00:00 2001 From: Jiyun Kim Date: Wed, 12 Apr 2023 16:59:30 +0900 Subject: [PATCH 13/80] =?UTF-8?q?#2=20:=2015650=5FN=EA=B3=BC=20M(2)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../15650_N\352\263\274 M(2).py" | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 "\354\235\264\355\213\260\354\247\200\354\234\244/15650_N\352\263\274 M(2).py" diff --git "a/\354\235\264\355\213\260\354\247\200\354\234\244/15650_N\352\263\274 M(2).py" "b/\354\235\264\355\213\260\354\247\200\354\234\244/15650_N\352\263\274 M(2).py" new file mode 100644 index 0000000..ef55bd5 --- /dev/null +++ "b/\354\235\264\355\213\260\354\247\200\354\234\244/15650_N\352\263\274 M(2).py" @@ -0,0 +1,10 @@ +import itertools +n, m = map(int, input().split()) + +nums = [ i for i in range(1, n+1)] #1~n까지 nums에 넣기 + +arr = itertools.combinations(nums, m) #중복 제외, 순서 상관없는 조합 만들기 +for i in arr: + for j in i: + print(j, end=' ') + print() \ No newline at end of file From 30a47d304ae3f19bf79e3108a98aa7efa7a30ec1 Mon Sep 17 00:00:00 2001 From: yjhss <20211420.sungshin.ac.kr> Date: Wed, 12 Apr 2023 19:23:47 +0900 Subject: [PATCH 14/80] =?UTF-8?q?#2=20:=201978=5F=EC=86=8C=EC=88=98=20?= =?UTF-8?q?=EC=B0=BE=EA=B8=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...206\214\354\210\230 \354\260\276\352\270\260.py" | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 "\354\235\264\355\213\260\354\234\240\354\247\204/1978_\354\206\214\354\210\230 \354\260\276\352\270\260.py" diff --git "a/\354\235\264\355\213\260\354\234\240\354\247\204/1978_\354\206\214\354\210\230 \354\260\276\352\270\260.py" "b/\354\235\264\355\213\260\354\234\240\354\247\204/1978_\354\206\214\354\210\230 \354\260\276\352\270\260.py" new file mode 100644 index 0000000..66d5447 --- /dev/null +++ "b/\354\235\264\355\213\260\354\234\240\354\247\204/1978_\354\206\214\354\210\230 \354\260\276\352\270\260.py" @@ -0,0 +1,13 @@ +n = int(input()) # 수의 개수 N 입력 받기 +numbers = map(int, input().split()) # N개의 수 입력 받기 +count = 0 # 소수의 개수를 세기 위한 변수 count 초기화 + +for num in numbers: + a = 0 + if num > 1 : + for i in range(2, num): # 2부터 (num-1)까지 (자기자신 제외) + if num % i == 0: + a += 1 # 2와 (num-1) 사이 숫자로 나누어 떨어지면 a 1씩 증가 + if a == 0: + count += 1 # a == 0 이면 소수이므로 count 1씩 증가 +print(count) \ No newline at end of file From 30ef9f5717ef5f2ceca089e56d834b4429dfb225 Mon Sep 17 00:00:00 2001 From: yjhss <20211420.sungshin.ac.kr> Date: Wed, 12 Apr 2023 19:29:19 +0900 Subject: [PATCH 15/80] =?UTF-8?q?#2=20:=2015650=5FN=EA=B3=BC=20M(2)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../15650_N\352\263\274 M(2).py" | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 "\354\235\264\355\213\260\354\234\240\354\247\204/15650_N\352\263\274 M(2).py" diff --git "a/\354\235\264\355\213\260\354\234\240\354\247\204/15650_N\352\263\274 M(2).py" "b/\354\235\264\355\213\260\354\234\240\354\247\204/15650_N\352\263\274 M(2).py" new file mode 100644 index 0000000..5cba603 --- /dev/null +++ "b/\354\235\264\355\213\260\354\234\240\354\247\204/15650_N\352\263\274 M(2).py" @@ -0,0 +1,12 @@ +from itertools import combinations #itertools의 combinations 함수 + +n,m = map(int, input().split()) # N과 M 입력받기 + +a = [] # [1,2,3,4 ..] +for i in range(1,n+1): + a.append(i) + +for i in combinations(a,m): # a에서 원소 개수 m개인 조합을 뽑는 것, 출력 + for j in i: + print(j,end=' ') + print() \ No newline at end of file From 4955a355f915ba0858536e2782cc636198a74a89 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=95=88=EC=98=88=EC=9B=90?= <78153914+yewonahn@users.noreply.github.com> Date: Wed, 12 Apr 2023 22:46:25 +0900 Subject: [PATCH 16/80] =?UTF-8?q?Create=2015650=5FN=EA=B3=BC=20M(2).py?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../15650_N\352\263\274 M(2).py" | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 "\354\235\264\355\213\260\354\230\210\354\233\220/15650_N\352\263\274 M(2).py" diff --git "a/\354\235\264\355\213\260\354\230\210\354\233\220/15650_N\352\263\274 M(2).py" "b/\354\235\264\355\213\260\354\230\210\354\233\220/15650_N\352\263\274 M(2).py" new file mode 100644 index 0000000..b3a00a8 --- /dev/null +++ "b/\354\235\264\355\213\260\354\230\210\354\233\220/15650_N\352\263\274 M(2).py" @@ -0,0 +1,21 @@ +n = int(input()) +num = list(range(1, n)) +m = int(input()) + +'t번째 자리' + +result=[] +def pick(t): + for a in range(n-m+1): + if t != 1 and result != []: + if result[t-2] < num[t-1+a]: + result.append(num[t-1+a]) + if t= 2: + del result[t-2] + +pick(1) From a6b7916b9015119f5407e59813c1d10b0b9d60bc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=95=88=EC=98=88=EC=9B=90?= <78153914+yewonahn@users.noreply.github.com> Date: Wed, 12 Apr 2023 22:50:12 +0900 Subject: [PATCH 17/80] =?UTF-8?q?#2=201978=5F=EC=86=8C=EC=88=98=20?= =?UTF-8?q?=EC=B0=BE=EA=B8=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...4\354\210\230 \354\260\276\352\270\260.py" | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 "\354\235\264\355\213\260\354\230\210\354\233\220/1978_\354\206\214\354\210\230 \354\260\276\352\270\260.py" diff --git "a/\354\235\264\355\213\260\354\230\210\354\233\220/1978_\354\206\214\354\210\230 \354\260\276\352\270\260.py" "b/\354\235\264\355\213\260\354\230\210\354\233\220/1978_\354\206\214\354\210\230 \354\260\276\352\270\260.py" new file mode 100644 index 0000000..f87c378 --- /dev/null +++ "b/\354\235\264\355\213\260\354\230\210\354\233\220/1978_\354\206\214\354\210\230 \354\260\276\352\270\260.py" @@ -0,0 +1,23 @@ +import sys + +n = int(input()) +print(n) +m = [*map(int,sys.stdin.readline().split())] +print(m) +count = 0 + +for i in m: + if i != 1 and i != 2: + for a in range(i): + if a != 0 and a != 1: + if i % a == 0: + break + elif a == i-1: + count += 1 + break + else: + count += 1 + elif i == 2: + count += 1 + +print(count) From 000f5872ce323194ac3a577c778fa4e0514e9a4e Mon Sep 17 00:00:00 2001 From: Jiyun Kim Date: Thu, 13 Apr 2023 00:47:46 +0900 Subject: [PATCH 18/80] =?UTF-8?q?#2=20:=201978=5F=EC=86=8C=EC=88=98=20?= =?UTF-8?q?=EC=B0=BE=EA=B8=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../1978_\354\206\214\354\210\230 \354\260\276\352\270\260.py" | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git "a/\354\235\264\355\213\260\354\247\200\354\234\244/1978_\354\206\214\354\210\230 \354\260\276\352\270\260.py" "b/\354\235\264\355\213\260\354\247\200\354\234\244/1978_\354\206\214\354\210\230 \354\260\276\352\270\260.py" index 4aefe48..b0cc742 100644 --- "a/\354\235\264\355\213\260\354\247\200\354\234\244/1978_\354\206\214\354\210\230 \354\260\276\352\270\260.py" +++ "b/\354\235\264\355\213\260\354\247\200\354\234\244/1978_\354\206\214\354\210\230 \354\260\276\352\270\260.py" @@ -5,9 +5,9 @@ # 입력받은 n개의 숫자 ex: [1, 3, 5, 7] prime_cnt=0 #소수 갯수 -isPrime = True #소수 여부 for i in nums: + isPrime = True #소수 여부 if i == 1: continue for j in range(2, i): # nums에 있는 숫자 i를 2부터 i-1까지 나눔 From 15945349246ec7359d72a070c39850c74dfb5f18 Mon Sep 17 00:00:00 2001 From: Sung-won Yang <86403488+Suanna01@users.noreply.github.com> Date: Thu, 13 Apr 2023 01:01:10 +0900 Subject: [PATCH 19/80] Update README.md --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 6257316..169eb12 100644 --- a/README.md +++ b/README.md @@ -14,7 +14,7 @@ ## ☑️ 참여방법 오프라인 : 목요일 오후 1시 성신여대 -온라인 : 목요일 오후 1시트구글미트 +온라인 : 목요일 오후 1시 구글미트 ## ☑️ Commit 규칙 #<매주 생성되는 해당 주차의 과제 공지 이슈 번호> : <백준문제번호>_<백준문제이름> @@ -62,7 +62,7 @@
💙유진이티💙
-

+

@@ -72,7 +72,7 @@

🖤지윤이티🖤
-

+

From 9b68882c8086ea181fed6f3288501c5bb7dd7b0a Mon Sep 17 00:00:00 2001 From: Sung-won Yang <86403488+Suanna01@users.noreply.github.com> Date: Thu, 13 Apr 2023 01:03:55 +0900 Subject: [PATCH 20/80] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 169eb12..45c8927 100644 --- a/README.md +++ b/README.md @@ -72,7 +72,7 @@
🖤지윤이티🖤
-

+

From a7383d51ee9d0f05d84363d2c386143bf65bd7b9 Mon Sep 17 00:00:00 2001 From: plum-king Date: Thu, 13 Apr 2023 12:41:04 +0900 Subject: [PATCH 21/80] =?UTF-8?q?#2=20:=2015650=5FN=EA=B3=BC=20M(2)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../15650_N\352\263\274 M(2).py" | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 "\354\235\264\353\213\210\354\247\200\354\210\230/15650_N\352\263\274 M(2).py" diff --git "a/\354\235\264\353\213\210\354\247\200\354\210\230/15650_N\352\263\274 M(2).py" "b/\354\235\264\353\213\210\354\247\200\354\210\230/15650_N\352\263\274 M(2).py" new file mode 100644 index 0000000..c2643b0 --- /dev/null +++ "b/\354\235\264\353\213\210\354\247\200\354\210\230/15650_N\352\263\274 M(2).py" @@ -0,0 +1,9 @@ +import itertools + +n, m = map(int, input().split()) +numlist = list(range(1, n+1)) +num = list(itertools.combinations(numlist ,m)) +for i in num: + for j in i: + print(j, end= ' ') + print() \ No newline at end of file From 1fe0fcd75502db1ed685fc7c6bc0838b6cdc5a97 Mon Sep 17 00:00:00 2001 From: Seong Joon Hee Date: Thu, 13 Apr 2023 14:32:35 +0900 Subject: [PATCH 22/80] =?UTF-8?q?#10=20:=20=ED=94=84=EB=A1=9C=EA=B7=B8?= =?UTF-8?q?=EB=9E=98=EB=A8=B8=EC=8A=A4=20Level=202=20=EC=A0=84=ED=99=94?= =?UTF-8?q?=EB=B2=88=ED=98=B8=20=EB=AA=A9=EB=A1=9D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...0\355\230\270 \353\252\251\353\241\235.py" | 59 +++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 "\354\235\264\355\213\260\354\244\200\355\235\254/\355\224\204\353\241\234\352\267\270\353\236\230\353\250\270\354\212\244 Level 2 \354\240\204\355\231\224\353\262\210\355\230\270 \353\252\251\353\241\235.py" diff --git "a/\354\235\264\355\213\260\354\244\200\355\235\254/\355\224\204\353\241\234\352\267\270\353\236\230\353\250\270\354\212\244 Level 2 \354\240\204\355\231\224\353\262\210\355\230\270 \353\252\251\353\241\235.py" "b/\354\235\264\355\213\260\354\244\200\355\235\254/\355\224\204\353\241\234\352\267\270\353\236\230\353\250\270\354\212\244 Level 2 \354\240\204\355\231\224\353\262\210\355\230\270 \353\252\251\353\241\235.py" new file mode 100644 index 0000000..e2093b7 --- /dev/null +++ "b/\354\235\264\355\213\260\354\244\200\355\235\254/\355\224\204\353\241\234\352\267\270\353\236\230\353\250\270\354\212\244 Level 2 \354\240\204\355\231\224\353\262\210\355\230\270 \353\252\251\353\241\235.py" @@ -0,0 +1,59 @@ +#2023-04-13-Week2 +#프로그래머스 Level 2 전화번호 목록.py + +#hash <- dict : key, value + +''' +문제 설명 +전화번호부에 적힌 전화번호 중, 한 번호가 다른 번호의 접두어인 경우가 있는지 확인하려 합니다. +전화번호가 다음과 같을 경우, 구조대 전화번호는 영석이의 전화번호의 접두사입니다. + +구조대 : 119 +박준영 : 97 674 223 +지영석 : 11 9552 4421 +전화번호부에 적힌 전화번호를 담은 배열 phone_book 이 solution 함수의 매개변수로 주어질 때, 어떤 번호가 다른 번호의 접두어인 경우가 있으면 false를 그렇지 않으면 true를 return 하도록 solution 함수를 작성해주세요. + +제한 사항 +phone_book의 길이는 1 이상 1,000,000 이하입니다. +각 전화번호의 길이는 1 이상 20 이하입니다. +같은 전화번호가 중복해서 들어있지 않습니다. +''' + +#key value 동일하게 초기화 + +''' +문자열에 원하는 문자가 있는지 확인하는 방법 in 문자열 + +text = "hello joonhee" + +if "joon" in text : + print("T") +else : + print("F") +''' + + +def solution(phone_book): + answer = True + hash = {} + + for i in phone_book : + hash[i] = 0 + + print(hash) + print("--------") + + for i in phone_book : + print(i) + print("--------") + + temp ='' + for j in i : + temp+=j + if temp in hash and temp != i : + answer = False + return answer + +#print(solution(["12","3456","789"])) +solution(["12","3456","789"]) + From 79b802e39c4309c6ef500a4e7ff287001eaef276 Mon Sep 17 00:00:00 2001 From: Seong Joon Hee Date: Thu, 13 Apr 2023 19:14:43 +0900 Subject: [PATCH 23/80] =?UTF-8?q?#2=20:=201978=5F=EC=86=8C=EC=88=98=20?= =?UTF-8?q?=EC=B0=BE=EA=B8=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...8_\354\206\214\354\210\230 \354\260\276\352\270\260.py" | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git "a/\354\235\264\355\213\260\354\244\200\355\235\254/1978_\354\206\214\354\210\230 \354\260\276\352\270\260.py" "b/\354\235\264\355\213\260\354\244\200\355\235\254/1978_\354\206\214\354\210\230 \354\260\276\352\270\260.py" index 621245a..284f05f 100644 --- "a/\354\235\264\355\213\260\354\244\200\355\235\254/1978_\354\206\214\354\210\230 \354\260\276\352\270\260.py" +++ "b/\354\235\264\355\213\260\354\244\200\355\235\254/1978_\354\206\214\354\210\230 \354\260\276\352\270\260.py" @@ -7,7 +7,8 @@ 결과 - 입력2의 자연수 중 소수의 개수 출력 ''' -n = int(input("입력 : \n")) +n = int(input()) +#feedback ) n = int(input("입력 : \n")) -> input 내부에 추가적인 멘트 작성 x num = list(map (int, input().split())) # 입력 받는 값 여러 개 -> map 함수 : 자료형, 함수 (.split() 공백으로 구분) @@ -25,7 +26,9 @@ if cnt == 1 : # 약수의 개수 1개 result += 1 # 소수 개수 추가 -print ("출력 : ", result) # 출력 : 입력 자연수 중 소수의 개수 +print (result) # 출력 : 입력 자연수 중 소수의 개수 + +#feedback ) print ("출력 : ", result) -> 출력시 추가적인 멘트 x From f857ba8a225553c2ceb2fecbcb3c6103ac3ebf7e Mon Sep 17 00:00:00 2001 From: Seong Joon Hee Date: Thu, 13 Apr 2023 19:15:28 +0900 Subject: [PATCH 24/80] =?UTF-8?q?#2=20:=2015650=5FN=EA=B3=BC=20M(2)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../15650_N\352\263\274 M(2).py" | 22 ++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git "a/\354\235\264\355\213\260\354\244\200\355\235\254/15650_N\352\263\274 M(2).py" "b/\354\235\264\355\213\260\354\244\200\355\235\254/15650_N\352\263\274 M(2).py" index 1c1ad5f..38afafe 100644 --- "a/\354\235\264\355\213\260\354\244\200\355\235\254/15650_N\352\263\274 M(2).py" +++ "b/\354\235\264\355\213\260\354\244\200\355\235\254/15650_N\352\263\274 M(2).py" @@ -13,10 +13,12 @@ 수열은 사전 순으로 증가하는 순서로 출력해야 한다. ''' -import itertools -n,m = map(int,input().split()) +''' +#feedback ) combinations 만 사용해도 풀이 가능 +from itertools +n,m = map(int,input().split()) num = itertools.combinations([i for i in range(1,n+1)],m) for i in num : @@ -26,4 +28,18 @@ print(" ".join(map(str, k))) #map k의 요소들을 문자열로 반환 #join 리스트 요소를 문자열로 연결 - #" "로 요소 사이에 구분자 \ No newline at end of file + #" "로 요소 사이에 구분자 +''' +from itertools import combinations + +n,m = map(int,input().split()) + +arr = [] +for i in range(1,n+1): + arr.append(i) + +for i in combinations(arr,m): + for j in i: + print(j, end=' ') + print() + From 9ab42c1f1d31437a5eed802d3865a12da44e9859 Mon Sep 17 00:00:00 2001 From: Sung-won Yang <86403488+Suanna01@users.noreply.github.com> Date: Fri, 14 Apr 2023 14:34:10 +0900 Subject: [PATCH 25/80] Update README.md --- README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 45c8927..281e611 100644 --- a/README.md +++ b/README.md @@ -42,17 +42,17 @@
❤️성원이니❤️
-

+

🧡지수이니🧡
-

+

💛지우이니💛
-

+

@@ -67,7 +67,7 @@

💜준희이티💜
-

+

From a94cda80b25b1a0620bd0366e73e5d97435f4aba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=95=88=EC=98=88=EC=9B=90?= <78153914+yewonahn@users.noreply.github.com> Date: Wed, 26 Apr 2023 13:53:43 +0900 Subject: [PATCH 26/80] =?UTF-8?q?#3=20:=2011279=5F=EC=B5=9C=EB=8C=80=20?= =?UTF-8?q?=ED=9E=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit #3 : Week3_예원이티 --- ..._\354\265\234\353\214\200 \355\236\231.py" | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 "11279_\354\265\234\353\214\200 \355\236\231.py" diff --git "a/11279_\354\265\234\353\214\200 \355\236\231.py" "b/11279_\354\265\234\353\214\200 \355\236\231.py" new file mode 100644 index 0000000..74bee4e --- /dev/null +++ "b/11279_\354\265\234\353\214\200 \355\236\231.py" @@ -0,0 +1,24 @@ +import heapq +import sys + +heap = [] + +#연산의 개수 N을 입력받는다 +n = int(input()) + +for i in range(n): + + #연산에 대한 정보를 나타내는 정수 x가 주어진다 + x = int(sys.stdin.readline()) + + #x가 0이라면 + if x == 0: + #배열의 요소가 있는 경우, + #배열에서 가장 큰 갑을 출력 + if heap: + print((-1)*heapq.heappop(heap)) + else: + print(0) + else: + #파이썬에서 힙은 최소힙을 따르므로, 최대힙을 구현하기 위해서 *(-1) + heapq.heappush(heap, (-1)*x) From 48ebe588d75a745678b123b811238fe1d409e373 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=95=88=EC=98=88=EC=9B=90?= <78153914+yewonahn@users.noreply.github.com> Date: Wed, 26 Apr 2023 13:54:45 +0900 Subject: [PATCH 27/80] =?UTF-8?q?Delete=2011279=5F=EC=B5=9C=EB=8C=80=20?= =?UTF-8?q?=ED=9E=99.py?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ..._\354\265\234\353\214\200 \355\236\231.py" | 24 ------------------- 1 file changed, 24 deletions(-) delete mode 100644 "11279_\354\265\234\353\214\200 \355\236\231.py" diff --git "a/11279_\354\265\234\353\214\200 \355\236\231.py" "b/11279_\354\265\234\353\214\200 \355\236\231.py" deleted file mode 100644 index 74bee4e..0000000 --- "a/11279_\354\265\234\353\214\200 \355\236\231.py" +++ /dev/null @@ -1,24 +0,0 @@ -import heapq -import sys - -heap = [] - -#연산의 개수 N을 입력받는다 -n = int(input()) - -for i in range(n): - - #연산에 대한 정보를 나타내는 정수 x가 주어진다 - x = int(sys.stdin.readline()) - - #x가 0이라면 - if x == 0: - #배열의 요소가 있는 경우, - #배열에서 가장 큰 갑을 출력 - if heap: - print((-1)*heapq.heappop(heap)) - else: - print(0) - else: - #파이썬에서 힙은 최소힙을 따르므로, 최대힙을 구현하기 위해서 *(-1) - heapq.heappush(heap, (-1)*x) From 0ddbb214ef90998dd860e3177eec0fcc588c1401 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=95=88=EC=98=88=EC=9B=90?= <78153914+yewonahn@users.noreply.github.com> Date: Wed, 26 Apr 2023 13:56:09 +0900 Subject: [PATCH 28/80] =?UTF-8?q?#3=20:=2011279=5F=EC=B5=9C=EB=8C=80=20?= =?UTF-8?q?=ED=9E=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit #3 : Week3_예원이티 --- ..._\354\265\234\353\214\200 \355\236\231.py" | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 "\354\235\264\355\213\260\354\230\210\354\233\220/11279_\354\265\234\353\214\200 \355\236\231.py" diff --git "a/\354\235\264\355\213\260\354\230\210\354\233\220/11279_\354\265\234\353\214\200 \355\236\231.py" "b/\354\235\264\355\213\260\354\230\210\354\233\220/11279_\354\265\234\353\214\200 \355\236\231.py" new file mode 100644 index 0000000..74bee4e --- /dev/null +++ "b/\354\235\264\355\213\260\354\230\210\354\233\220/11279_\354\265\234\353\214\200 \355\236\231.py" @@ -0,0 +1,24 @@ +import heapq +import sys + +heap = [] + +#연산의 개수 N을 입력받는다 +n = int(input()) + +for i in range(n): + + #연산에 대한 정보를 나타내는 정수 x가 주어진다 + x = int(sys.stdin.readline()) + + #x가 0이라면 + if x == 0: + #배열의 요소가 있는 경우, + #배열에서 가장 큰 갑을 출력 + if heap: + print((-1)*heapq.heappop(heap)) + else: + print(0) + else: + #파이썬에서 힙은 최소힙을 따르므로, 최대힙을 구현하기 위해서 *(-1) + heapq.heappush(heap, (-1)*x) From da61eee8473403d2b64895c584caa9bee8a5c377 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=95=88=EC=98=88=EC=9B=90?= <78153914+yewonahn@users.noreply.github.com> Date: Wed, 26 Apr 2023 13:57:16 +0900 Subject: [PATCH 29/80] =?UTF-8?q?#3=20:=201966=5F=ED=94=84=EB=A6=B0?= =?UTF-8?q?=ED=84=B0=ED=81=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit #3 : Week3_예원이티 --- ...04\353\246\260\355\204\260\355\201\220.py" | 41 +++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 "\354\235\264\355\213\260\354\230\210\354\233\220/1966_\355\224\204\353\246\260\355\204\260\355\201\220.py" diff --git "a/\354\235\264\355\213\260\354\230\210\354\233\220/1966_\355\224\204\353\246\260\355\204\260\355\201\220.py" "b/\354\235\264\355\213\260\354\230\210\354\233\220/1966_\355\224\204\353\246\260\355\204\260\355\201\220.py" new file mode 100644 index 0000000..24a2b64 --- /dev/null +++ "b/\354\235\264\355\213\260\354\230\210\354\233\220/1966_\355\224\204\353\246\260\355\204\260\355\201\220.py" @@ -0,0 +1,41 @@ +import sys + +#테스트 케이스 개수 +total = int(input()) +arr = [] + +for a in range(total): + + #문서의 개수 n, 궁금한 문서의 인덱스m + n, m = map(int, input().split()) + + #문서의 인덱스와 중요도를 묶은 리스트 + arr = list(enumerate(list(map(int,input().split())))) + + #순서를 알고싶은 문서의 인덱스와 중요도를 묶은 리스트 + printer = arr[m] + + #count) 해당 문서가 인쇄된 순서를 저장 + count = 0 + + while len(arr): + + #big) 배열의 가장 높은 우선순위 + big = max(i[1] for i in arr) + + #제일 앞에 있는 문서의 우선순위가 가장 높다면 + if arr[0][1] == big: + #해당 문서를 pop() + nowIdx = arr.pop(0) + count += 1 + + if nowIdx == printer: + print(count) + break + + #제일 앞에 있는 문서의 우선순위가 가장 높지 않다면 + else: + #제일 앞에서 빼고 + nowIdx = arr.pop(0) + #제일 마지막에 넣어준다 + arr.append(nowIdx) From 9815ccf3889a70acf93f4c6f2815dde5df71538e Mon Sep 17 00:00:00 2001 From: Seong Joon Hee Date: Wed, 26 Apr 2023 14:14:13 +0900 Subject: [PATCH 30/80] =?UTF-8?q?#10=20:=2011279=5F=EC=B5=9C=EB=8C=80=20?= =?UTF-8?q?=ED=9E=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ..._\354\265\234\353\214\200 \355\236\231.py" | 55 +++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 "\354\235\264\355\213\260\354\244\200\355\235\254/11279_\354\265\234\353\214\200 \355\236\231.py" diff --git "a/\354\235\264\355\213\260\354\244\200\355\235\254/11279_\354\265\234\353\214\200 \355\236\231.py" "b/\354\235\264\355\213\260\354\244\200\355\235\254/11279_\354\265\234\353\214\200 \355\236\231.py" new file mode 100644 index 0000000..49d8518 --- /dev/null +++ "b/\354\235\264\355\213\260\354\244\200\355\235\254/11279_\354\265\234\353\214\200 \355\236\231.py" @@ -0,0 +1,55 @@ +#2023-04-15-Week2-과제 +#11279_최대 힙 + +''' +배열에 자연수 x를 넣는다. +배열에서 가장 큰 값을 출력하고, 그 값을 배열에서 제거한다. +프로그램은 처음에 비어있는 배열에서 시작하게 된다. + +첫째 줄에 연산의 개수 N(1 ≤ N ≤ 100,000)이 주어진다. +다음 N개의 줄에는 연산에 대한 정보를 나타내는 정수 x가 +주어진다. 만약 x가 자연수라면 배열에 x라는 값을 넣는(추가하는) 연산이고, +x가 0이라면 배열에서 가장 큰 값을 출력하고 +그 값을 배열에서 제거하는 경우이다. +입력되는 자연수는 231보다 작다. + +입력에서 0이 주어진 회수만큼 답을 출력한다. +만약 배열이 비어 있는 경우인데 +가장 큰 값을 출력하라고 한 경우에는 0을 출력하면 된다. +''' + + +''' +import heapq +heap = [] +num = int(input()) + +for i in range(num) : + a = int(input()) + if a==0: + if heap : + print(heapq.heappop(heap)[1]) + else : + print(0) + elif a>0 : + heapq.heappush(heap, (-a,a)) +''' + +#채점 결과 시간 초과 +#input() -> sys.stdin.readline() + +import heapq +import sys +heap = [] +num = int(sys.stdin.readline()) + +for i in range(num) : + a = int(sys.stdin.readline()) + if a==0: #a가 0이라면 + if heap : + print(heapq.heappop(heap)[1]) # 배열에서 가장 큰 값을 출력하고 그 값을 배열에서 제거하는 경우이다. + else : # + print(0) + elif a>0 : #a가 자연수라면 + heapq.heappush(heap, (-a,a)) #a라는 값을 넣는 연산 + \ No newline at end of file From f2addccad3f5cba8cf7dd06f7c3a9d082070e160 Mon Sep 17 00:00:00 2001 From: Seong Joon Hee Date: Wed, 26 Apr 2023 14:14:28 +0900 Subject: [PATCH 31/80] =?UTF-8?q?#10=20:=201966=5F=ED=94=84=EB=A6=B0?= =?UTF-8?q?=ED=84=B0=20=ED=81=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...4\353\246\260\355\204\260 \355\201\220.py" | 58 +++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 "\354\235\264\355\213\260\354\244\200\355\235\254/1966_\355\224\204\353\246\260\355\204\260 \355\201\220.py" diff --git "a/\354\235\264\355\213\260\354\244\200\355\235\254/1966_\355\224\204\353\246\260\355\204\260 \355\201\220.py" "b/\354\235\264\355\213\260\354\244\200\355\235\254/1966_\355\224\204\353\246\260\355\204\260 \355\201\220.py" new file mode 100644 index 0000000..7cd2703 --- /dev/null +++ "b/\354\235\264\355\213\260\354\244\200\355\235\254/1966_\355\224\204\353\246\260\355\204\260 \355\201\220.py" @@ -0,0 +1,58 @@ +#2023-04-15-Week2-과제 +#1966_프린터 큐 + +''' +여러분도 알다시피 여러분의 프린터 기기는 여러분이 인쇄하고자 하는 문서를 +인쇄 명령을 받은 ‘순서대로’, 즉 먼저 요청된 것을 먼저 인쇄한다. +여러 개의 문서가 쌓인다면 Queue 자료구조에 쌓여서 +FIFO - First In First Out - 에 따라 인쇄가 되게 된다. +하지만 상근이는 새로운 프린터기 내부 소프트웨어를 개발하였는데, +이 프린터기는 다음과 같은 조건에 따라 인쇄를 하게 된다. + +현재 Queue의 가장 앞에 있는 문서의 ‘중요도’를 확인한다. +나머지 문서들 중 현재 문서보다 중요도가 높은 문서가 하나라도 있다면, +이 문서를 인쇄하지 않고 Queue의 가장 뒤에 재배치 한다. +그렇지 않다면 바로 인쇄를 한다. +예를 들어 Queue에 4개의 문서(A B C D)가 있고, 중요도가 2 1 4 3 라면 C를 인쇄하고, +다음으로 D를 인쇄하고 A, B를 인쇄하게 된다. + +여러분이 할 일은, 현재 Queue에 있는 문서의 수와 중요도가 주어졌을 때, +어떤 한 문서가 몇 번째로 인쇄되는지 알아내는 것이다. +예를 들어 위의 예에서 C문서는 1번째로, A문서는 3번째로 인쇄되게 된다. + +입력 +첫 줄에 테스트케이스의 수가 주어진다. 각 테스트케이스는 두 줄로 이루어져 있다. +테스트케이스의 첫 번째 줄에는 문서의 개수 N(1 ≤ N ≤ 100)과, +몇 번째로 인쇄되었는지 궁금한 문서가 현재 Queue에서 +몇 번째에 놓여 있는지를 나타내는 정수 M(0 ≤ M < N)이 주어진다. +이때 맨 왼쪽은 0번째라고 하자. 두 번째 줄에는 N개 문서의 중요도가 차례대로 주어진다. +중요도는 1 이상 9 이하의 정수이고, 중요도가 같은 문서가 여러 개 있을 수도 있다. + +''' + +#큐 = FIFO + +t = int(input()) + +for i in range(t): + + n, m = map(int, input().split()) + queue = list(map(int, input().split())) + cnt = 0 + + while m != -1: + if queue[0] == max(queue): + del queue[0] + m -= 1 + cnt += 1 + else: + queue.append(queue[0]) + del queue[0] + + if m==0 : + m = len(queue) -1 + else : + m -= 1 + +#print(cnt) -> 오답 원인 : print문 위치 + print(cnt) From 85d858d2f7e8cc6337e28cb23a1df955235eda23 Mon Sep 17 00:00:00 2001 From: Jiyun Kim Date: Wed, 26 Apr 2023 18:17:35 +0900 Subject: [PATCH 32/80] =?UTF-8?q?#10=20:=2011279=5F=EC=B5=9C=EB=8C=80=20?= =?UTF-8?q?=ED=9E=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ..._\354\265\234\353\214\200 \355\236\231.py" | 17 +++++++++++++++++ ...4\353\246\260\355\204\260 \355\201\220.py" | 19 +++++++++++++++++++ ...0\355\230\270 \353\252\251\353\241\235.py" | 17 +++++++++++++++++ 3 files changed, 53 insertions(+) create mode 100644 "\354\235\264\355\213\260\354\247\200\354\234\244/11279_\354\265\234\353\214\200 \355\236\231.py" create mode 100644 "\354\235\264\355\213\260\354\247\200\354\234\244/1966_\355\224\204\353\246\260\355\204\260 \355\201\220.py" create mode 100644 "\354\235\264\355\213\260\354\247\200\354\234\244/\355\224\204\353\241\234\352\267\270\353\236\230\353\250\270\354\212\244_\354\240\204\355\231\224\353\262\210\355\230\270 \353\252\251\353\241\235.py" diff --git "a/\354\235\264\355\213\260\354\247\200\354\234\244/11279_\354\265\234\353\214\200 \355\236\231.py" "b/\354\235\264\355\213\260\354\247\200\354\234\244/11279_\354\265\234\353\214\200 \355\236\231.py" new file mode 100644 index 0000000..6bc8506 --- /dev/null +++ "b/\354\235\264\355\213\260\354\247\200\354\234\244/11279_\354\265\234\353\214\200 \355\236\231.py" @@ -0,0 +1,17 @@ +# for문 안의 num = int(input()) # 이 방법 시간초과=> 반복문으로 여러 줄 받을 때 input()은 시간초과 발생 + +import heapq, sys + +heap = [] +n = int(input()) + +for i in range(n): + num = int(sys.stdin.readline()) # 한 줄 입력 받아 정수형으로 형변환 + if num == 0: # 0 입력되면 + if heap: # 힙에 요소 있을 때 가장 큰 값 첫번째 루트 노드 삭제 + print(heapq.heappop(heap)[1]) + else:# 비어있을 때 0 출력 + print(0) + else: # 자연수 입력되면 + heapq.heappush(heap, (-num, num)) # (우선순위, 값) + diff --git "a/\354\235\264\355\213\260\354\247\200\354\234\244/1966_\355\224\204\353\246\260\355\204\260 \355\201\220.py" "b/\354\235\264\355\213\260\354\247\200\354\234\244/1966_\355\224\204\353\246\260\355\204\260 \355\201\220.py" new file mode 100644 index 0000000..9002ee5 --- /dev/null +++ "b/\354\235\264\355\213\260\354\247\200\354\234\244/1966_\355\224\204\353\246\260\355\204\260 \355\201\220.py" @@ -0,0 +1,19 @@ +num = int(input()) + +for i in range(num): + N, M = map(int, input().split()) + queue = list(map(int, input().strip().split())) + queue = [(v, idx) for idx, v in enumerate(queue)] + + order = 0 + + while True: + if max(queue)[0] == queue[0][0]: + order += 1 + if queue[0][1] == M: + print(order) + break + else: + queue.pop(0) + else: + queue.append(queue.pop(0)) \ No newline at end of file diff --git "a/\354\235\264\355\213\260\354\247\200\354\234\244/\355\224\204\353\241\234\352\267\270\353\236\230\353\250\270\354\212\244_\354\240\204\355\231\224\353\262\210\355\230\270 \353\252\251\353\241\235.py" "b/\354\235\264\355\213\260\354\247\200\354\234\244/\355\224\204\353\241\234\352\267\270\353\236\230\353\250\270\354\212\244_\354\240\204\355\231\224\353\262\210\355\230\270 \353\252\251\353\241\235.py" new file mode 100644 index 0000000..29f260a --- /dev/null +++ "b/\354\235\264\355\213\260\354\247\200\354\234\244/\355\224\204\353\241\234\352\267\270\353\236\230\353\250\270\354\212\244_\354\240\204\355\231\224\353\262\210\355\230\270 \353\252\251\353\241\235.py" @@ -0,0 +1,17 @@ +def solution(phone_book): + answer = True + hash = {} + + for i in phone_book: + hash[i] = 0 + + for i in phone_book: + print(i) + temp = '' + for j in i: + temp += j + if temp in hash and temp != i: + answer = False + return answer + +print(solution(["34", "3456", "789"])) \ No newline at end of file From f9570f2f0cfb45129df0c1d203082dd65e6de71d Mon Sep 17 00:00:00 2001 From: yjhss <20211420.sungshin.ac.kr> Date: Wed, 26 Apr 2023 21:06:50 +0900 Subject: [PATCH 33/80] =?UTF-8?q?#10=20:=2011279=5F=EC=B5=9C=EB=8C=80=20?= =?UTF-8?q?=ED=9E=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...279_\354\265\234\353\214\200 \355\236\231.py" | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 "\354\235\264\355\213\260\354\234\240\354\247\204/11279_\354\265\234\353\214\200 \355\236\231.py" diff --git "a/\354\235\264\355\213\260\354\234\240\354\247\204/11279_\354\265\234\353\214\200 \355\236\231.py" "b/\354\235\264\355\213\260\354\234\240\354\247\204/11279_\354\265\234\353\214\200 \355\236\231.py" new file mode 100644 index 0000000..a2239aa --- /dev/null +++ "b/\354\235\264\355\213\260\354\234\240\354\247\204/11279_\354\265\234\353\214\200 \355\236\231.py" @@ -0,0 +1,16 @@ +import sys +import heapq + +n = int(sys.stdin.readline()) +heap = [] + +# -1을 곱해 최소 힙으로 최대 힙 구현 +for i in range (n): + x = int(sys.stdin.readline()) + if x == 0: # x가 0일 때 + if heap: # 배열에서 가장 큰 값 출력하고 그 값을 배열에서 삭제 + print((-1)*heapq.heappop(heap)) + else: # 배열이 비어있을 경우 0 출력 + print(0) + elif x > 0: # x가 자연수일 때 + heapq.heappush(heap,(-1)*x) # 배열에 x라는 값 추가 From a1e7e02139e15a49555f30834643784bd1215065 Mon Sep 17 00:00:00 2001 From: yjhss <20211420.sungshin.ac.kr> Date: Wed, 26 Apr 2023 21:59:22 +0900 Subject: [PATCH 34/80] =?UTF-8?q?#10=20:=201966=5F=ED=94=84=EB=A6=B0?= =?UTF-8?q?=ED=84=B0=20=ED=81=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...4\353\246\260\355\204\260 \355\201\220.py" | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 "\354\235\264\355\213\260\354\234\240\354\247\204/1966_\355\224\204\353\246\260\355\204\260 \355\201\220.py" diff --git "a/\354\235\264\355\213\260\354\234\240\354\247\204/1966_\355\224\204\353\246\260\355\204\260 \355\201\220.py" "b/\354\235\264\355\213\260\354\234\240\354\247\204/1966_\355\224\204\353\246\260\355\204\260 \355\201\220.py" new file mode 100644 index 0000000..5a540ed --- /dev/null +++ "b/\354\235\264\355\213\260\354\234\240\354\247\204/1966_\355\224\204\353\246\260\355\204\260 \355\201\220.py" @@ -0,0 +1,24 @@ +import sys + +t = int(sys.stdin.readline()) # 테스트 케이스 개수 t + +for i in range (t): + n, m = map(int, input().split()) + queue = list(map(int, input().split())) # 리스트 queue + cnt = 0 # 문서의 출력 순서를 세기 위한 변수 cnt + + while queue: + if queue[0] == max(queue): # 맨 앞 문서의 중요도가 가장 클 때 + del queue[0] # 맨 앞 문서 삭제 + m -= 1 # 문서 위치 왼쪽으로 한 번 이동하므로 m 값 1 감소 + cnt +=1 # 문서 하나 출력 되었으므로 cnt 값 1 증가 + else: # 맨 앞 문서의 중요도가 가장 크지 않을 때 + queue.append(queue[0]) # 이 문서를 맨 뒤에 추가 + del queue[0] # 맨 앞에서 삭제 + + if m == 0: # m이 0일 경우 + m = len(queue)-1 # m 맨 뒤 가리킴 + else: # m이 0이 아닐 경우 + m -= 1 # m 값 1 감소 + + print(cnt) # cnt 값 출력 \ No newline at end of file From fdf4febd35b6af5d1bc59047a9601365d3881d31 Mon Sep 17 00:00:00 2001 From: Seong Joon Hee Date: Thu, 27 Apr 2023 22:20:13 +0900 Subject: [PATCH 35/80] =?UTF-8?q?#14=20:=2011729=5F=ED=95=98=EB=85=B8?= =?UTF-8?q?=EC=9D=B4=20=ED=83=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...30\353\205\270\354\235\264\355\203\221.py" | 55 +++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 "\354\235\264\355\213\260\354\244\200\355\235\254/11729_\355\225\230\353\205\270\354\235\264\355\203\221.py" diff --git "a/\354\235\264\355\213\260\354\244\200\355\235\254/11729_\355\225\230\353\205\270\354\235\264\355\203\221.py" "b/\354\235\264\355\213\260\354\244\200\355\235\254/11729_\355\225\230\353\205\270\354\235\264\355\203\221.py" new file mode 100644 index 0000000..981f7e9 --- /dev/null +++ "b/\354\235\264\355\213\260\354\244\200\355\235\254/11729_\355\225\230\353\205\270\354\235\264\355\203\221.py" @@ -0,0 +1,55 @@ +#2023-04-27-Week3 +#11729_하노이 탑.py + + +''' +하노이탑 원판 1개인 경우 -> top(1, 1, 2, 3) +이동 과정 +1. 1번 1->3 + +하노이탑 원판 2개인 경우 -> top(2, 1, 2, 3) +이동 과정 +1. 1번 1->2 +2. 2번 1->3 +3. 1번 2->3 + +하노이탑 원판 3개인 경우 -> top(3, 1, 2, 3) +이동 과정 +1. 1번 1->3 +2. 2번 1->2 +3. 1번 3->2 +4. 3번 1->3 +5. 1번 2->1 +6. 2번 2->3 +7. 1번 1->3 + +''' + +n = int(input()) + +def cnt(n) : + if n==1 : + k = 2 + elif n<=0 : + k = 1 + else : + k = 2*cnt(n-1) + return k + +def top(n, a, b, c) : + if n==1 : + print(a,c) + else : + #else 코드는 스스로 작성하지 못함 + top(n-1,a,c,b) + print(a,c) + top(n-1,b,a,c) + +''' +함수 쓰지 않고 바로 계산해도 됨 +sum = 2**n-1 +print(sum) +''' +print(cnt(n)) +top(n, 1, 2, 3) + From 49d4e5511baf7a71769fd6ab601e5cf913708a01 Mon Sep 17 00:00:00 2001 From: yjhss <20211420.sungshin.ac.kr> Date: Wed, 3 May 2023 01:15:57 +0900 Subject: [PATCH 36/80] =?UTF-8?q?#10=20:=201966=5F=ED=94=84=EB=A6=B0?= =?UTF-8?q?=ED=84=B0=20=ED=81=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...4\353\246\260\355\204\260 \355\201\220.py" | 35 ++++++++----------- 1 file changed, 15 insertions(+), 20 deletions(-) diff --git "a/\354\235\264\355\213\260\354\234\240\354\247\204/1966_\355\224\204\353\246\260\355\204\260 \355\201\220.py" "b/\354\235\264\355\213\260\354\234\240\354\247\204/1966_\355\224\204\353\246\260\355\204\260 \355\201\220.py" index 5a540ed..cffb0e8 100644 --- "a/\354\235\264\355\213\260\354\234\240\354\247\204/1966_\355\224\204\353\246\260\355\204\260 \355\201\220.py" +++ "b/\354\235\264\355\213\260\354\234\240\354\247\204/1966_\355\224\204\353\246\260\355\204\260 \355\201\220.py" @@ -1,24 +1,19 @@ import sys +from collections import deque -t = int(sys.stdin.readline()) # 테스트 케이스 개수 t - -for i in range (t): - n, m = map(int, input().split()) - queue = list(map(int, input().split())) # 리스트 queue - cnt = 0 # 문서의 출력 순서를 세기 위한 변수 cnt +t = int(sys.stdin.readline()) #테스트 케이스 수 t +for i in range(t): + n, m = map(int,input().split()) + queue = deque(list(map(int,input().split()))) #문서 중요도 queue + index_queue = deque(list(range(n))) #인덱스 idx_queue + cnt = 0 #인쇄 순서 cnt while queue: - if queue[0] == max(queue): # 맨 앞 문서의 중요도가 가장 클 때 - del queue[0] # 맨 앞 문서 삭제 - m -= 1 # 문서 위치 왼쪽으로 한 번 이동하므로 m 값 1 감소 - cnt +=1 # 문서 하나 출력 되었으므로 cnt 값 1 증가 - else: # 맨 앞 문서의 중요도가 가장 크지 않을 때 - queue.append(queue[0]) # 이 문서를 맨 뒤에 추가 - del queue[0] # 맨 앞에서 삭제 - - if m == 0: # m이 0일 경우 - m = len(queue)-1 # m 맨 뒤 가리킴 - else: # m이 0이 아닐 경우 - m -= 1 # m 값 1 감소 - - print(cnt) # cnt 값 출력 \ No newline at end of file + if queue[0] == max(queue): #queue의 첫번째 원소가 최댓값인 경우(가장 앞에 있는 문서의 중요도가 가장 클 경우) pop + cnt += 1 #pop할 때마다 cnt 1씩 증가 + queue.popleft() + if index_queue.popleft() == m: #pop한 문서의 인덱스가 m과 같다면 cnt 출력 + print(cnt) + else: + queue.append(queue.popleft()) #queue의 첫번째 원소가 최댓값 아닌 경우 맨 뒤로 재배치 + index_queue.append(index_queue.popleft()) \ No newline at end of file From b64116ca2976e20c6204de180f275f448c5bf6e0 Mon Sep 17 00:00:00 2001 From: Seong Joon Hee Date: Wed, 3 May 2023 02:43:59 +0900 Subject: [PATCH 37/80] =?UTF-8?q?#14=20:=2011650=5F=EC=A2=8C=ED=91=9C=20?= =?UTF-8?q?=EC=A0=95=EB=A0=AC=ED=95=98=EA=B8=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...25\353\240\254\355\225\230\352\270\260.py" | 31 +++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 "\354\235\264\355\213\260\354\244\200\355\235\254/11650_\354\242\214\355\221\234 \354\240\225\353\240\254\355\225\230\352\270\260.py" diff --git "a/\354\235\264\355\213\260\354\244\200\355\235\254/11650_\354\242\214\355\221\234 \354\240\225\353\240\254\355\225\230\352\270\260.py" "b/\354\235\264\355\213\260\354\244\200\355\235\254/11650_\354\242\214\355\221\234 \354\240\225\353\240\254\355\225\230\352\270\260.py" new file mode 100644 index 0000000..4bf98d4 --- /dev/null +++ "b/\354\235\264\355\213\260\354\244\200\355\235\254/11650_\354\242\214\355\221\234 \354\240\225\353\240\254\355\225\230\352\270\260.py" @@ -0,0 +1,31 @@ +#2023-04-27-Week3-과제 +#11650_좌표 정렬하기 + +''' +문제 +2차원 평면 위의 점 N개가 주어진다. +좌표를 x좌표가 증가하는 순으로, +x좌표가 같으면 y좌표가 증가하는 순서로 정렬한 다음 +출력하는 프로그램을 작성하시오. + +입력 +첫째 줄에 점의 개수 N (1 ≤ N ≤ 100,000)이 주어진다. +둘째 줄부터 N개의 줄에는 i번점의 위치 xi와 yi가 주어진다. +(-100,000 ≤ xi, yi ≤ 100,000) 좌표는 항상 정수이고, +위치가 같은 두 점은 없다. + +출력 +첫째 줄부터 N개의 줄에 점을 정렬한 결과를 출력한다. +''' + +N = int(input()) +array = [] + +for i in range(N): + a,b = map(int,input().split()) + array.append((a,b)) + +array.sort() + +for j in range(N): + print(array[j][0],array[j][1]) #a b 출력 \ No newline at end of file From f8afe8ab48bda99b56821273afb35bef1b52e827 Mon Sep 17 00:00:00 2001 From: Jiyun Kim Date: Wed, 3 May 2023 15:56:27 +0900 Subject: [PATCH 38/80] =?UTF-8?q?#14=20:=2011729=5F=ED=95=98=EB=85=B8?= =?UTF-8?q?=EC=9D=B4=20=ED=83=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...0\353\205\270\354\235\264 \355\203\221.py" | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 "\354\235\264\355\213\260\354\247\200\354\234\244/11729_\355\225\230\353\205\270\354\235\264 \355\203\221.py" diff --git "a/\354\235\264\355\213\260\354\247\200\354\234\244/11729_\355\225\230\353\205\270\354\235\264 \355\203\221.py" "b/\354\235\264\355\213\260\354\247\200\354\234\244/11729_\355\225\230\353\205\270\354\235\264 \355\203\221.py" new file mode 100644 index 0000000..b39847c --- /dev/null +++ "b/\354\235\264\355\213\260\354\247\200\354\234\244/11729_\355\225\230\353\205\270\354\235\264 \355\203\221.py" @@ -0,0 +1,22 @@ +#11729_하노이 탑 + +n = int(input()) + +#n: 원판 수 +#a,b,c : 3개의 장대 +def top(n, a, b, c):# n개의 원판을 a에서 c로 옮기는 하노이 탑 + + # 원판 1개 : a->c로 옮기면 끝 + if n == 1: + print(a, c) + + # 재귀 + else: + top(n-1, a, c, b) # a에 있는 원판 n-1 개를 b로 옮김 + print(a, c) # a에 남아 있던 가장 큰 n번 원반을 c로 옮김 + top(n-1, b, a, c) # b의 n-1 개의 원반을 c로 옮김 + +sum = 2 ** n - 1 # 이동 횟수 = 2^n-1 +print(sum) + +top(n, 1, 2, 3) \ No newline at end of file From f69831b353eccb46d5d231a33e24c9a1005d8a79 Mon Sep 17 00:00:00 2001 From: Jiyun Kim Date: Wed, 3 May 2023 17:28:19 +0900 Subject: [PATCH 39/80] =?UTF-8?q?#14=20:=2011650=5F=EC=A2=8C=ED=91=9C=20?= =?UTF-8?q?=EC=A0=95=EB=A0=AC=ED=95=98=EA=B8=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...25\353\240\254\355\225\230\352\270\260.py" | 42 +++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 "\354\235\264\355\213\260\354\247\200\354\234\244/11650_\354\242\214\355\221\234 \354\240\225\353\240\254\355\225\230\352\270\260.py" diff --git "a/\354\235\264\355\213\260\354\247\200\354\234\244/11650_\354\242\214\355\221\234 \354\240\225\353\240\254\355\225\230\352\270\260.py" "b/\354\235\264\355\213\260\354\247\200\354\234\244/11650_\354\242\214\355\221\234 \354\240\225\353\240\254\355\225\230\352\270\260.py" new file mode 100644 index 0000000..92f9228 --- /dev/null +++ "b/\354\235\264\355\213\260\354\247\200\354\234\244/11650_\354\242\214\355\221\234 \354\240\225\353\240\254\355\225\230\352\270\260.py" @@ -0,0 +1,42 @@ +import sys +input = sys.stdin.readline + +n = int(input()) # 입력할 좌표 수 : 2차원 배열의 크기 + +def merge_sort(arr): + if len(arr) < 2: + return arr + mid = len(arr) // 2 + left = merge_sort(arr[:mid]) + right = merge_sort(arr[mid:]) + merged_arr = [] + l = r = 0 + + while l < len(left) and r < len(right): + # x 좌표가 같을 경우 : y좌표를 비교해서 작은 값 리스트에 넣기 + #[][0] : x좌표, [][1] : y좌표인 2차원 배열 + if left[l][0] == right[r][0]: + if left[l][1] < right[r][1]: + merged_arr.append(left[l]) + l += 1 + else: + merged_arr.append(right[r]) + r += 1 + elif left[l][0] < right[r][0]: + merged_arr.append(left[l]) + l += 1 + else: + merged_arr.append(right[r]) + r += 1 + + merged_arr += left[l:] + merged_arr += right[r:] + + return merged_arr + +# 입력받은 문자열 n개의 행을 int형 2차원 리스트로 변환-> a에 할당 +a = [list(map(int,input().split())) for i in range(n)] +a = merge_sort(a) + +for i in a: + print(i[0],i[1]) \ No newline at end of file From ce063908d82ff7231fbaa2c8840db23a4cf515e9 Mon Sep 17 00:00:00 2001 From: Jiyun Kim Date: Wed, 3 May 2023 18:15:12 +0900 Subject: [PATCH 40/80] =?UTF-8?q?#14=20:=201431=5F=EC=8B=9C=EB=A6=AC?= =?UTF-8?q?=EC=96=BC=20=EB=B2=88=ED=98=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...4\354\226\274 \353\262\210\355\230\270.py" | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 "\354\235\264\355\213\260\354\247\200\354\234\244/1431_\354\213\234\353\246\254\354\226\274 \353\262\210\355\230\270.py" diff --git "a/\354\235\264\355\213\260\354\247\200\354\234\244/1431_\354\213\234\353\246\254\354\226\274 \353\262\210\355\230\270.py" "b/\354\235\264\355\213\260\354\247\200\354\234\244/1431_\354\213\234\353\246\254\354\226\274 \353\262\210\355\230\270.py" new file mode 100644 index 0000000..7f639ff --- /dev/null +++ "b/\354\235\264\355\213\260\354\247\200\354\234\244/1431_\354\213\234\353\246\254\354\226\274 \353\262\210\355\230\270.py" @@ -0,0 +1,29 @@ +#1431_시리얼 번호 +# sort 함수 이용 +# 시리얼번호 : 알파벳 대문자(A-Z) ,숫자(0-9) 로 이루어짐 +# 1. 길이 짧은 것이 앞으로 +# 2. 길이 같을 때, a의 모든 자리수의 합(숫자만)과 b의 모든 자리수의 합(숫자만) 중에 작은 합이 앞으로 +# 3. 1,2번 조건으로도 비교 안되면, 사전 순으로 -> 숫자가 알파벳 보다 앞 +# lamda식을 이용한 정렬 arr.sort(key = lambda x : (정렬기준1, 정렬기준2, 정렬기준3, …)) + +import sys +n = int(input()) + +def sum_num(num): + result = 0 # result : 모든 자리수의 합 + for i in num: + if i.isdigit(): # isdisit() : 문자열이 숫자인지 true/false + result += int(i) + return result + +arr = [] +for i in range(n): + arr.append(sys.stdin.readline().strip()) + +# 1. len(x) = 길이 +# 2. sum_num(x) = 모든 자리수의 합 +# 3. x = 사전순 +arr.sort(key = lambda x:(len(x), sum_num(x), x)) + +for i in arr: + print(i) \ No newline at end of file From ceb7c2452f390063ef19c14541d3bd8c1c34340d Mon Sep 17 00:00:00 2001 From: Seong Joon Hee Date: Thu, 4 May 2023 02:36:52 +0900 Subject: [PATCH 41/80] =?UTF-8?q?#14=20:=201431=5F=EC=8B=9C=EB=A6=AC?= =?UTF-8?q?=EC=96=BC=20=EB=B2=88=ED=98=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...4\354\226\274 \353\262\210\355\230\270.py" | 55 +++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 "\354\235\264\355\213\260\354\244\200\355\235\254/1431_\354\213\234\353\246\254\354\226\274 \353\262\210\355\230\270.py" diff --git "a/\354\235\264\355\213\260\354\244\200\355\235\254/1431_\354\213\234\353\246\254\354\226\274 \353\262\210\355\230\270.py" "b/\354\235\264\355\213\260\354\244\200\355\235\254/1431_\354\213\234\353\246\254\354\226\274 \353\262\210\355\230\270.py" new file mode 100644 index 0000000..4ecb6da --- /dev/null +++ "b/\354\235\264\355\213\260\354\244\200\355\235\254/1431_\354\213\234\353\246\254\354\226\274 \353\262\210\355\230\270.py" @@ -0,0 +1,55 @@ +#2023-04-27-Week3-과제 +#1431_시리얼 번호 + +''' +문제 +다솜이는 기타를 많이 가지고 있다. +그리고 각각의 기타는 모두 다른 시리얼 번호를 가지고 있다. +다솜이는 기타를 빨리 찾아서 빨리 사람들에게 연주해주기 위해서 +기타를 시리얼 번호 순서대로 정렬하고자 한다. + +모든 시리얼 번호는 알파벳 대문자 (A-Z)와 숫자 (0-9)로 이루어져 있다. +시리얼번호 A가 시리얼번호 B의 앞에 오는 경우는 다음과 같다. + +A와 B의 길이가 다르면, 짧은 것이 먼저 온다. + +만약 서로 길이가 같다면, +A의 모든 자리수의 합과 B의 모든 자리수의 합을 비교해서 +작은 합을 가지는 것이 먼저온다. (숫자인 것만 더한다) + +만약 1,2번 둘 조건으로도 비교할 수 없으면, +사전순으로 비교한다. 숫자가 알파벳보다 사전순으로 작다. +시리얼이 주어졌을 때, 정렬해서 출력하는 프로그램을 작성하시오. + +입력 +첫째 줄에 기타의 개수 N이 주어진다. +N은 50보다 작거나 같다. +둘째 줄부터 N개의 줄에 시리얼 번호가 하나씩 주어진다. +시리얼 번호의 길이는 최대 50이고, 알파벳 대문자 또는 숫자로만 이루어져 있다. +시리얼 번호는 중복되지 않는다. + +출력 +첫째 줄부터 차례대로 N개의 줄에 한줄에 하나씩 +시리얼 번호를 정렬한 결과를 출력한다. +''' + +#익명 함수 호출을 위한 lambda / 정렬을 위한 sort 사용 가능 + +N = int(input()) + +a = [] + +for i in range(N) : + a.append(input()) + +def sum (x) : + sum = 0 + for i in x : + if (x>='0') and (x<='9') : + sum += int(x) + return sum + +a = sorted(list, key= lambda x: (len(x), sum(x), x)) + +for i in a : + print(i) \ No newline at end of file From 28d4d8639f9eddce8c0254f47c9e2f073acd9ffd Mon Sep 17 00:00:00 2001 From: yjhss <20211420.sungshin.ac.kr> Date: Thu, 4 May 2023 07:28:30 +0900 Subject: [PATCH 42/80] =?UTF-8?q?#14=20:=2011650=5F=EC=A2=8C=ED=91=9C=20?= =?UTF-8?q?=EC=A0=95=EB=A0=AC=ED=95=98=EA=B8=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...25\353\240\254\355\225\230\352\270\260.py" | 45 +++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 "\354\235\264\355\213\260\354\234\240\354\247\204/11650_\354\242\214\355\221\234 \354\240\225\353\240\254\355\225\230\352\270\260.py" diff --git "a/\354\235\264\355\213\260\354\234\240\354\247\204/11650_\354\242\214\355\221\234 \354\240\225\353\240\254\355\225\230\352\270\260.py" "b/\354\235\264\355\213\260\354\234\240\354\247\204/11650_\354\242\214\355\221\234 \354\240\225\353\240\254\355\225\230\352\270\260.py" new file mode 100644 index 0000000..ea57f3b --- /dev/null +++ "b/\354\235\264\355\213\260\354\234\240\354\247\204/11650_\354\242\214\355\221\234 \354\240\225\353\240\254\355\225\230\352\270\260.py" @@ -0,0 +1,45 @@ +import sys + +n = int(sys.stdin.readline()) #n 입력 + +arr = [list(map(int,input().split())) for i in range(n)] #2차원 평면 위의 점 n개 입력 [[3,4],[1,1]] + +#병합정렬_merge +def merge(left, right): + i, j = 0, 0 + sorted_list = [] + while(i < len(left)) and (j < len(right)): + if left[i] < right[j]: + sorted_list.append(left[i]) + i += 1 + else: + sorted_list.append(right[j]) + j += 1 + if i == len(left): + while j < len(right): + sorted_list.append(right[j]) + j += 1 + elif j == len(right): + while i < len(left): + sorted_list.append(left[i]) + i += 1 + return sorted_list + +#병합정렬_merge sort +def merge_sort(arr): + if len(arr) <= 1: + return arr + #분할하고 분할된 리스트 각각 정렬 + mid = len(arr) // 2 + left = merge_sort(arr[:mid]) + right = merge_sort(arr[mid:]) + #병합 + return merge(left,right) + +#정렬 +arr = merge_sort(arr) +#좌표 출력 +for x, y in arr: + print(x,y) + + From 69ad8d491ef67aceb55d9d6531d9fd6567e403f7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=95=88=EC=98=88=EC=9B=90?= <78153914+yewonahn@users.noreply.github.com> Date: Thu, 4 May 2023 08:39:13 +0900 Subject: [PATCH 43/80] =?UTF-8?q?#14=20:=2011650=5F=EC=A2=8C=ED=91=9C=20?= =?UTF-8?q?=EC=A0=95=EB=A0=AC=ED=95=98=EA=B8=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit #14 : Week3_예원이티 --- ...240\225\353\240\254\355\225\230\352\270\260.py" | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 "\354\235\264\355\213\260\354\230\210\354\233\220/11650_\354\242\214\355\221\234 \354\240\225\353\240\254\355\225\230\352\270\260.py" diff --git "a/\354\235\264\355\213\260\354\230\210\354\233\220/11650_\354\242\214\355\221\234 \354\240\225\353\240\254\355\225\230\352\270\260.py" "b/\354\235\264\355\213\260\354\230\210\354\233\220/11650_\354\242\214\355\221\234 \354\240\225\353\240\254\355\225\230\352\270\260.py" new file mode 100644 index 0000000..1c808fe --- /dev/null +++ "b/\354\235\264\355\213\260\354\230\210\354\233\220/11650_\354\242\214\355\221\234 \354\240\225\353\240\254\355\225\230\352\270\260.py" @@ -0,0 +1,14 @@ +import sys + +n = int(sys.stdin.readline()) + +array = [] + +for _ in range(n): + x, y = map(int, input().split()) + array.append((x, y)) + +array.sort(key = lambda x: (x[0], x[1])) + +for x, y in array: + print(x, y) From 3902c536643fd96acb01901637739300b5334846 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=95=88=EC=98=88=EC=9B=90?= <78153914+yewonahn@users.noreply.github.com> Date: Thu, 4 May 2023 08:45:21 +0900 Subject: [PATCH 44/80] =?UTF-8?q?#14=20:=2011729=5F=ED=95=98=EB=85=B8?= =?UTF-8?q?=EC=9D=B4=20=ED=83=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit #14 : Week3_예원이티 --- ...\230\353\205\270\354\235\264 \355\203\221.py" | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 "\354\235\264\355\213\260\354\230\210\354\233\220/11729_\355\225\230\353\205\270\354\235\264 \355\203\221.py" diff --git "a/\354\235\264\355\213\260\354\230\210\354\233\220/11729_\355\225\230\353\205\270\354\235\264 \355\203\221.py" "b/\354\235\264\355\213\260\354\230\210\354\233\220/11729_\355\225\230\353\205\270\354\235\264 \355\203\221.py" new file mode 100644 index 0000000..12ac4c8 --- /dev/null +++ "b/\354\235\264\355\213\260\354\230\210\354\233\220/11729_\355\225\230\353\205\270\354\235\264 \355\203\221.py" @@ -0,0 +1,16 @@ +n = int(input()) + +def top(n, a, b, c): + + if n == 1: + print(a, c) + + else: + top(n-1, a, c, b) + print(a, c) + top(n-1, b, a, c) + +sum = 2 ** n -1 +print(sum) + +top(n, 1, 2, 3) From 03e25210341ce00116a2e0b83282042592286a81 Mon Sep 17 00:00:00 2001 From: yjhss <20211420.sungshin.ac.kr> Date: Thu, 4 May 2023 08:55:42 +0900 Subject: [PATCH 45/80] =?UTF-8?q?#14=20:=201431=5F=EC=8B=9C=EB=A6=AC?= =?UTF-8?q?=EC=96=BC=20=EB=B2=88=ED=98=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...4\354\226\274 \353\262\210\355\230\270.py" | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 "\354\235\264\355\213\260\354\234\240\354\247\204/1431_\354\213\234\353\246\254\354\226\274 \353\262\210\355\230\270.py" diff --git "a/\354\235\264\355\213\260\354\234\240\354\247\204/1431_\354\213\234\353\246\254\354\226\274 \353\262\210\355\230\270.py" "b/\354\235\264\355\213\260\354\234\240\354\247\204/1431_\354\213\234\353\246\254\354\226\274 \353\262\210\355\230\270.py" new file mode 100644 index 0000000..6f3a063 --- /dev/null +++ "b/\354\235\264\355\213\260\354\234\240\354\247\204/1431_\354\213\234\353\246\254\354\226\274 \353\262\210\355\230\270.py" @@ -0,0 +1,22 @@ +import sys + +n = int(sys.stdin.readline()) #기타 개수 n 입력 +s = [input() for i in range(n)] #시리얼 번호 n개 입력 + +#정렬 2_자릿수 합 +def sum(x): + r = 0 + for i in x: + if i.isdigit(): #isdigit(): 문자열이 숫자인지 판별 + r += int (i) + return r + +#정렬_ 1.길이 2.자릿수 합 3.사전순 +s.sort(key = lambda x: (len(x), sum(x), x)) + +#정렬된 리스트 s의 모든 요소 출력 +for i in s: + print(i) + + + From 2c30414fc440c0d92ae1847fb6530fe260dde9a3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=95=88=EC=98=88=EC=9B=90?= <78153914+yewonahn@users.noreply.github.com> Date: Thu, 4 May 2023 09:51:07 +0900 Subject: [PATCH 46/80] =?UTF-8?q?#14=20:=201431=5F=EC=8B=9C=EB=A6=AC?= =?UTF-8?q?=EC=96=BC=20=EB=B2=88=ED=98=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit #14 : Week3_예원이티 --- ...4\354\226\274 \353\262\210\355\230\270.py" | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 "\354\235\264\355\213\260\354\230\210\354\233\220/1431_\354\213\234\353\246\254\354\226\274 \353\262\210\355\230\270.py" diff --git "a/\354\235\264\355\213\260\354\230\210\354\233\220/1431_\354\213\234\353\246\254\354\226\274 \353\262\210\355\230\270.py" "b/\354\235\264\355\213\260\354\230\210\354\233\220/1431_\354\213\234\353\246\254\354\226\274 \353\262\210\355\230\270.py" new file mode 100644 index 0000000..575be7f --- /dev/null +++ "b/\354\235\264\355\213\260\354\230\210\354\233\220/1431_\354\213\234\353\246\254\354\226\274 \353\262\210\355\230\270.py" @@ -0,0 +1,20 @@ +import sys + +n = int(sys.stdin.readline()) + +guitar = [] + +for _ in range(n): + guitar.append(sys.stdin.readline().strip()) + +def serialSum(str): + sum = 0 + for i in str: + if i.isdigit(): + sum += int(i) + return sum + +guitar.sort(key = lambda x : (len(x), serialSum(x), x)) + +for a in guitar: + print(a) From 722b824d6376fd4ffde0f5c32bbee1c0a3cfb693 Mon Sep 17 00:00:00 2001 From: Seong Joon Hee Date: Thu, 4 May 2023 09:54:49 +0900 Subject: [PATCH 47/80] =?UTF-8?q?#14=20:=201431=5F=EC=8B=9C=EB=A6=AC?= =?UTF-8?q?=EC=96=BC=20=EB=B2=88=ED=98=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...34\353\246\254\354\226\274 \353\262\210\355\230\270.py" | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git "a/\354\235\264\355\213\260\354\244\200\355\235\254/1431_\354\213\234\353\246\254\354\226\274 \353\262\210\355\230\270.py" "b/\354\235\264\355\213\260\354\244\200\355\235\254/1431_\354\213\234\353\246\254\354\226\274 \353\262\210\355\230\270.py" index 4ecb6da..90313b7 100644 --- "a/\354\235\264\355\213\260\354\244\200\355\235\254/1431_\354\213\234\353\246\254\354\226\274 \353\262\210\355\230\270.py" +++ "b/\354\235\264\355\213\260\354\244\200\355\235\254/1431_\354\213\234\353\246\254\354\226\274 \353\262\210\355\230\270.py" @@ -35,12 +35,15 @@ #익명 함수 호출을 위한 lambda / 정렬을 위한 sort 사용 가능 -N = int(input()) +import sys + +#N = int(input()) +N = int((sys.stdin.readline())) a = [] for i in range(N) : - a.append(input()) + a.append(sys.stdin.readline()) def sum (x) : sum = 0 From f595a418422f3ba468ac89eafd066683226c2ed6 Mon Sep 17 00:00:00 2001 From: Sung-won Yang <86403488+Suanna01@users.noreply.github.com> Date: Fri, 5 May 2023 17:25:27 +0900 Subject: [PATCH 48/80] Update README.md --- README.md | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 281e611..92fe889 100644 --- a/README.md +++ b/README.md @@ -42,37 +42,37 @@

❤️성원이니❤️
-

+

🧡지수이니🧡
-

+

💛지우이니💛
-

+

💚예원이티💚
-

+

💙유진이티💙
-

+

💜준희이티💜
-

+

🖤지윤이티🖤
-

+

From 210580b0a1329619f851fbb4eb18ddc8abc32244 Mon Sep 17 00:00:00 2001 From: Seong Joon Hee Date: Wed, 10 May 2023 13:13:21 +0900 Subject: [PATCH 49/80] =?UTF-8?q?#17=20:=202579=5F=EA=B3=84=EB=8B=A8=20?= =?UTF-8?q?=EC=98=A4=EB=A5=B4=EA=B8=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...0 \354\230\244\353\245\264\352\270\260.py" | 69 +++++++++++++++++++ 1 file changed, 69 insertions(+) create mode 100644 "\354\235\264\355\213\260\354\244\200\355\235\254/2579_\352\263\204\353\213\250 \354\230\244\353\245\264\352\270\260.py" diff --git "a/\354\235\264\355\213\260\354\244\200\355\235\254/2579_\352\263\204\353\213\250 \354\230\244\353\245\264\352\270\260.py" "b/\354\235\264\355\213\260\354\244\200\355\235\254/2579_\352\263\204\353\213\250 \354\230\244\353\245\264\352\270\260.py" new file mode 100644 index 0000000..2a0bf00 --- /dev/null +++ "b/\354\235\264\355\213\260\354\244\200\355\235\254/2579_\352\263\204\353\213\250 \354\230\244\353\245\264\352\270\260.py" @@ -0,0 +1,69 @@ + +#2023-05-04-Week3-과제 +#2579_계단 오르기 + + +import sys +input = sys.stdin.readline + +n = int(input()) #계단 개수 +score = [0 for i in range(301)] #계단 점수 리스트 -> 계단의 개수 300이하의 자연수 +dynamic = [0 for i in range(301)] #동적 계획법 리스트 -> 계단의 개수 300이하의 자연수 + +for i in range(n) : + score[i] = int(input()) #계단 개수만큼 점수 입력 + +''' +마지막 도착 계단은 반드시 밟아야 함 +-> 계단 개수 입력 값이 a일 때 + 마지막 도착 계단인 a번 계단을 x번째 차례에 밟은 계단이라고 하면 + x-1번째 차례에는 a-1번 계단이나 a-2번 계단을 밟았을 것 +-> a-1번 계단을 밟았다면 a-2번째 계단은 밟을 수 없음 + +해당 인덱스번째 계단까지의 최댓값을 +동적 계획법 리스트에 저장 + +i번 계단까지 최댓값 += i-2번 계단까지 점수를 고려한 최댓값 + i번 계단의 점수 , + i-3번 계단까지 점수를 고려한 최댓값 + i-1번 계단의 점수 + 중 더 큰 값 (max로 비교) +''' + +dynamic[0] = score[0] +dynamic[1] = score[0] + score[1] +dynamic[2] = max (score[1]+score[2], score[0]+score[2]) + +for i in range(3,n): + dynamic[i] = max(dynamic[i-3]+score[i-1]+score[i], dynamic[i-2]+score[i]) +print(dynamic[n-1]) + + +########################################################################################### +#미리 리스트의 공간을 모두 할당 받는(?)건 낭비인가? 싶어서 다시 작성해봤지만 런타임에러 뜸 + +n = int(input()) #계단 개수 +score = [] #계단 점수 리스트 -> 계단 개수만큼만 할당 +for x in range(n) : + score.append(int(input())) +dynamic = [] #동적 계획법 빈 리스트 + +if n == 1: + dynamic.append(score[0]) + print(dynamic[0]) +elif n == 2 : + dynamic.append(max(score[0]+score[1], score[1])) + print(sum(score)) +else : # n >= 3 + ''' + dynamic[0] = score[0] + dynamic[1] = score[0] + soore[1] + for i in range(2,n): + dynamic[i] = max(dynamic[i-3]+score[i-1]+score[i], dynamic[i-2]+score[i]) + print(score[-1]) + + ''' + dynamic.append(max(dynamic[i-2]+score[i] , dynamic[i-3]+score[i]+score[i - 1])) + +print(dynamic[-1]) #마지막으로 저장한 값 출력 -> d[n-1] == d[-1] == d.pop() + + From 714e95a8d140e9613c8bcc3896188429a13952ad Mon Sep 17 00:00:00 2001 From: Seong Joon Hee Date: Wed, 10 May 2023 13:22:41 +0900 Subject: [PATCH 50/80] =?UTF-8?q?#17=20:=202579=5F=EA=B3=84=EB=8B=A8=20?= =?UTF-8?q?=EC=98=A4=EB=A5=B4=EA=B8=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...63\204\353\213\250 \354\230\244\353\245\264\352\270\260.py" | 3 +++ 1 file changed, 3 insertions(+) diff --git "a/\354\235\264\355\213\260\354\244\200\355\235\254/2579_\352\263\204\353\213\250 \354\230\244\353\245\264\352\270\260.py" "b/\354\235\264\355\213\260\354\244\200\355\235\254/2579_\352\263\204\353\213\250 \354\230\244\353\245\264\352\270\260.py" index 2a0bf00..301b097 100644 --- "a/\354\235\264\355\213\260\354\244\200\355\235\254/2579_\352\263\204\353\213\250 \354\230\244\353\245\264\352\270\260.py" +++ "b/\354\235\264\355\213\260\354\244\200\355\235\254/2579_\352\263\204\353\213\250 \354\230\244\353\245\264\352\270\260.py" @@ -41,6 +41,9 @@ ########################################################################################### #미리 리스트의 공간을 모두 할당 받는(?)건 낭비인가? 싶어서 다시 작성해봤지만 런타임에러 뜸 +import sys +input = sys.stdin.readline #이렇게 해도 런타임에러 발생 + n = int(input()) #계단 개수 score = [] #계단 점수 리스트 -> 계단 개수만큼만 할당 for x in range(n) : From 4f6e2587007fa0a93cd8a42a07c0314df7a32bf3 Mon Sep 17 00:00:00 2001 From: yjhss <20211420.sungshin.ac.kr> Date: Wed, 10 May 2023 17:01:20 +0900 Subject: [PATCH 51/80] =?UTF-8?q?#17=20:=202579=5F=EA=B3=84=EB=8B=A8=20?= =?UTF-8?q?=EC=98=A4=EB=A5=B4=EA=B8=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...0 \354\230\244\353\245\264\352\270\260.py" | 51 +++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 "\354\235\264\355\213\260\354\234\240\354\247\204/2579_\352\263\204\353\213\250 \354\230\244\353\245\264\352\270\260.py" diff --git "a/\354\235\264\355\213\260\354\234\240\354\247\204/2579_\352\263\204\353\213\250 \354\230\244\353\245\264\352\270\260.py" "b/\354\235\264\355\213\260\354\234\240\354\247\204/2579_\352\263\204\353\213\250 \354\230\244\353\245\264\352\270\260.py" new file mode 100644 index 0000000..de27070 --- /dev/null +++ "b/\354\235\264\355\213\260\354\234\240\354\247\204/2579_\352\263\204\353\213\250 \354\230\244\353\245\264\352\270\260.py" @@ -0,0 +1,51 @@ +import sys + +#계단 개수 n 입력받기 +n = int(sys.stdin.readline()) + +#각 계단 점수 리스트에 입력받기 +s = [0] * 1000 # s = [] IndexError: 빈 리스트에 인덱스 지정하여 오류 -> 1. append 함수 이용 2. 리스트 미리 설정 +for i in range(n): + s[i] = int(sys.stdin.readline()) + +#점수 총합 최댓값 구하는 리스트 +dp = [0] * 1000 + +#계단 1개일 때 +dp[0] = s[0] #점수 총합 최댓값 = 첫번째 계단 점수 + +#계단 2개일 때 +dp[1] = s[0] + s[1] #점수 총합 최댓값 = 첫번째 계단 점수 + 두번째 계단 점수 + +#계단 3개 이상인 경우 +for i in range(2,n): + dp[i] = s[i] + max(dp[i-3]+s[i-1] , dp[i-2]) + +#계단 n개일 때 점수 총합 최댓값 출력 +print(dp[n-1]) + +''' +ex)계단 3개일 때 +i) 3<-2<-시작 +ii) 3<-1<-시작 +dp[2] = s[2] + max(s[1],s[0]) + +ex)계단 4개일 때 +i) 4<-3<-1<-시작 +ii) 4<-2<-1<-시작 +iii) 4<-2<-시작 +dp[3] = s[3] + max(s[0]+s[2], s[0]+s[1]) +dp[3] = s[3] + max(dp[0]+s[2], dp[1]) + +ex)계단 6개일 때 +i) 6<-5<-3<-2<-시작 +ii) 6<-5<-3<-1<-시작 +i, ii: 6<-5<-(n=3일 때 계단 오르기 경우의 수) +----------------------------------------- +iii) 6<-4<-3<-1<-시작 +iv) 6<-4<-2<-1<-시작 +v) 6<-4<-2<-시작 +iii, iv, v: 6<-(n=4일 때 계단 오르기 경우의 수) +dp[5] = s[5] + max(dp[2]+s[4], dp[3]) + +''' \ No newline at end of file From 772c060ae8cd1553a87568ac3a9898066856061d Mon Sep 17 00:00:00 2001 From: Jiyun Kim Date: Wed, 10 May 2023 21:53:30 +0900 Subject: [PATCH 52/80] =?UTF-8?q?#17=20:=202579=5F=EA=B3=84=EB=8B=A8=20?= =?UTF-8?q?=EC=98=A4=EB=A5=B4=EA=B8=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...50 \354\230\244\353\245\264\352\270\260.py" | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 "\354\235\264\355\213\260\354\247\200\354\234\244/2579_\352\263\204\353\213\250 \354\230\244\353\245\264\352\270\260.py" diff --git "a/\354\235\264\355\213\260\354\247\200\354\234\244/2579_\352\263\204\353\213\250 \354\230\244\353\245\264\352\270\260.py" "b/\354\235\264\355\213\260\354\247\200\354\234\244/2579_\352\263\204\353\213\250 \354\230\244\353\245\264\352\270\260.py" new file mode 100644 index 0000000..9761f30 --- /dev/null +++ "b/\354\235\264\355\213\260\354\247\200\354\234\244/2579_\352\263\204\353\213\250 \354\230\244\353\245\264\352\270\260.py" @@ -0,0 +1,18 @@ +import sys +input = sys.stdin.readline + +n = int(input()) # 계단 개수 +s = [int(input()) for _ in range(n)] # 계단 리스트 +dp = [0]*(n) # dp 리스트 + +if len(s)<=2: # 계단 2개 이하 + print(sum(s)) + +else: # 계단이 3개 이상일 때 + dp[0] = s[0] # 첫번째 계단 + dp[1] = s[0] + s[1] # 두번째 계단 + + for i in range(2,n): # 세번째 계단부터 dp점화식 + dp[i] = max(dp[i-3]+s[i-1]+s[i], dp[i-2]+s[i]) + + print(dp[-1]) \ No newline at end of file From 876aa1b9358a2b651f08741578530a4ea1f32398 Mon Sep 17 00:00:00 2001 From: Jiyun Kim Date: Wed, 10 May 2023 21:58:08 +0900 Subject: [PATCH 53/80] =?UTF-8?q?#17=20:=2011050=5F=EC=9D=B4=ED=95=AD=20?= =?UTF-8?q?=EA=B3=84=EC=88=98=201?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...4\355\225\255 \352\263\204\354\210\230 1.py" | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 "\354\235\264\355\213\260\354\247\200\354\234\244/11050_\354\235\264\355\225\255 \352\263\204\354\210\230 1.py" diff --git "a/\354\235\264\355\213\260\354\247\200\354\234\244/11050_\354\235\264\355\225\255 \352\263\204\354\210\230 1.py" "b/\354\235\264\355\213\260\354\247\200\354\234\244/11050_\354\235\264\355\225\255 \352\263\204\354\210\230 1.py" new file mode 100644 index 0000000..87f8b56 --- /dev/null +++ "b/\354\235\264\355\213\260\354\247\200\354\234\244/11050_\354\235\264\355\225\255 \352\263\204\354\210\230 1.py" @@ -0,0 +1,17 @@ +import sys +input = sys.stdin.readline + +n,k = map(int, input().split()) + +array = [[0 for _ in range(n+1)] for _ in range(n+1)] + +for i in range(n+1): + array[i][i] = 1 + array[i][0] = 1 + +for i in range(2,n+1): + for j in range(1,n+1): + if array[i][j] != 1: + array[i][j] = array[i-1][j-1] + array[i-1][j] + +print(array[n][k]) \ No newline at end of file From a1acf3756a12f6291b1a2355a5c7d36d7bb9ebba Mon Sep 17 00:00:00 2001 From: Jisoo Hwang <77599304+plum-king@users.noreply.github.com> Date: Thu, 11 May 2023 05:15:04 +0900 Subject: [PATCH 54/80] =?UTF-8?q?Create=205567=EB=BC=88=EB=8C=80.py?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../5567\353\274\210\353\214\200.py" | 38 +++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 "\354\235\264\353\213\210\354\247\200\354\210\230/5567\353\274\210\353\214\200.py" diff --git "a/\354\235\264\353\213\210\354\247\200\354\210\230/5567\353\274\210\353\214\200.py" "b/\354\235\264\353\213\210\354\247\200\354\210\230/5567\353\274\210\353\214\200.py" new file mode 100644 index 0000000..8fc1a8e --- /dev/null +++ "b/\354\235\264\353\213\210\354\247\200\354\210\230/5567\353\274\210\353\214\200.py" @@ -0,0 +1,38 @@ +# 5567 결혼식 + +# 입력 값 + +# 6 +# 5 +# 1 2 +# 1 3 +# 3 4 +# 2 3 +# 4 5 + +import sys +from collections import deque + +# N 과 M 입력 받는 방법 다름 +N = +M = + +graph = [[False] * (N + 1) for _ in range(N + 1)] + +for _ in range(M): + a, b = map(int, sys.stdin.readline().split()) + #그래프 초기 세팅 다름 + +visited = [0] * (N + 1) # false 대신 0 + +def bfs(V): + q = deque([V]) + visited[V] = 1 # 숫자 덧셈에 필요 + while q: + V = q.popleft() + for i in range(1, N + 1): #for문 범위 수정 + if not visited[i] and graph[V][i]: # visited[i] 관련 조건 다름 + q.append(i) + visited[i] = # visited[i] 구하는 방법 다름 +bfs(1) +# 추가 코드 From 145400580d257c07baba3aa963e927633ac18ae5 Mon Sep 17 00:00:00 2001 From: Jisoo Hwang <77599304+plum-king@users.noreply.github.com> Date: Thu, 11 May 2023 14:11:54 +0900 Subject: [PATCH 55/80] =?UTF-8?q?#21=20:=205567=5F=EA=B2=B0=ED=98=BC?= =?UTF-8?q?=EC=8B=9D.py?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...7_\352\262\260\355\230\274\354\213\235.py" | 43 +++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 "\354\235\264\353\213\210\354\247\200\354\210\230/5567_\352\262\260\355\230\274\354\213\235.py" diff --git "a/\354\235\264\353\213\210\354\247\200\354\210\230/5567_\352\262\260\355\230\274\354\213\235.py" "b/\354\235\264\353\213\210\354\247\200\354\210\230/5567_\352\262\260\355\230\274\354\213\235.py" new file mode 100644 index 0000000..c2bd080 --- /dev/null +++ "b/\354\235\264\353\213\210\354\247\200\354\210\230/5567_\352\262\260\355\230\274\354\213\235.py" @@ -0,0 +1,43 @@ +# 5567 결혼식 + +# 입력 값 + +# 6 +# 5 +# 1 2 +# 1 3 +# 3 4 +# 2 3 +# 4 5 + +import sys +from collections import deque + +N = int(sys.stdin.readline()) +M = int(sys.stdin.readline()) + +graph = [[False] * (N + 1) for _ in range(N + 1)] + +for _ in range(M): + a, b = map(int, sys.stdin.readline().split()) + graph[a].append(b) # a 인덱스에 b 넣기 + graph[b].append(a) # b 인덱스에 a 넣기 + +visited = [0] * (N + 1) # false 대신 0 넣기 -> 더해야돼서! + +def bfs(V): + q = deque([V]) + visited[V] = 1 + while q: + V = q.popleft() + for i in graph[V]: + if visited[i] == 0: + q.append(i) + visited[i] = visited[V] + 1 +bfs(1) +result = 0 +for i in range(2,N+1): + # 본인이거나 친구거나, 친구의 친구거나 경우의 수가 최대 3개 + if 0 < visited[i] <=3: + result += 1 +print(result) From b0cb552fd67eab0c28dd3c97d3340ca61e929433 Mon Sep 17 00:00:00 2001 From: jooon <98799034+SeongJoonhee@users.noreply.github.com> Date: Wed, 17 May 2023 00:08:05 +0900 Subject: [PATCH 56/80] =?UTF-8?q?5567=5F=EA=B2=B0=ED=98=BC=EC=8B=9D.py?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...7_\352\262\260\355\230\274\354\213\235.py" | 56 +++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 "\354\235\264\355\213\260\354\244\200\355\235\254/5567_\352\262\260\355\230\274\354\213\235.py" diff --git "a/\354\235\264\355\213\260\354\244\200\355\235\254/5567_\352\262\260\355\230\274\354\213\235.py" "b/\354\235\264\355\213\260\354\244\200\355\235\254/5567_\352\262\260\355\230\274\354\213\235.py" new file mode 100644 index 0000000..da3d05d --- /dev/null +++ "b/\354\235\264\355\213\260\354\244\200\355\235\254/5567_\352\262\260\355\230\274\354\213\235.py" @@ -0,0 +1,56 @@ +#2023-05-11-Week5-수업 +#5567_결혼식 + +''' +입력 값 +6 +5 +1 2 +1 3 +3 4 +2 3 +4 5 +''' + +#bfs + +import sys +from collections import deque + +''' +이렇게 작성했더니 런타임에러 +input = sys.stdin.readline() +N = int(input()) +M = int(input()) +''' + +N = int(sys.stdin.readline()) +M = int(sys.stdin.readline()) + +graph = [[False] * (N + 1) for i in range(N + 1)] #False 대신 0 가능 #1번 인덱스부터 사용 + +for i in range(M): + a, b = map(int, sys.stdin.readline().split()) + graph[a].append(b) # a 인덱스에 b 넣기 + graph[b].append(a) # b 인덱스에 a 넣기 + + #1번 인덱스 -> 본인 -> 본인의 친구 + +visited = [0] * (N + 1) # false 대신 0 이어야 함 -> 덧셈 연산 수행을 위해 int형 + +def bfs(vertex): + queue = deque([vertex]) + visited[vertex] = 1 + while queue: #queue==1일 때 반복 + vertex = queue.popleft() #deque의 popleft()은 list의 pop(0)와 같지만 O(1)임 + for i in graph[vertex]: + if visited[i] == 0: + queue.append(i) + visited[i] = visited[vertex] + 1 +bfs(1) +result = 0 #초대하는 동기의 수 +for i in range(2,N+1): + if (visited[i] != 0) and (visited[i] < 4) : # 본인/친구/친구의 친구 -> visited 수 범위 1~3 + #if 0 < visited[i] <=3 : 이게 더 간결함 + result += 1 #visited 범위에 해당하면 누적합 계산 +print(result) From 79f8d373201a9a69debb9e3562ebafac710583fe Mon Sep 17 00:00:00 2001 From: jooon <98799034+SeongJoonhee@users.noreply.github.com> Date: Wed, 17 May 2023 01:28:35 +0900 Subject: [PATCH 57/80] =?UTF-8?q?#21=20:=202606=5F=EB=B0=94=EC=9D=B4?= =?UTF-8?q?=EB=9F=AC=EC=8A=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...24\354\235\264\353\237\254\354\212\244.py" | 37 +++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 "\354\235\264\355\213\260\354\244\200\355\235\254/2606_\353\260\224\354\235\264\353\237\254\354\212\244.py" diff --git "a/\354\235\264\355\213\260\354\244\200\355\235\254/2606_\353\260\224\354\235\264\353\237\254\354\212\244.py" "b/\354\235\264\355\213\260\354\244\200\355\235\254/2606_\353\260\224\354\235\264\353\237\254\354\212\244.py" new file mode 100644 index 0000000..228fcc9 --- /dev/null +++ "b/\354\235\264\355\213\260\354\244\200\355\235\254/2606_\353\260\224\354\235\264\353\237\254\354\212\244.py" @@ -0,0 +1,37 @@ +#2023-05-11-Week5-과제 +#2606_바이러스 + +''' +입력 + +7 총 컴퓨터 수 +6 컴퓨터 간 연결된 선 개수 +1 2 1번컴퓨터와 2번컴퓨터 연결 +2 3 +... +4 7 +''' + +#bfs 너비 우선 탐색 +import sys +from collections import deque +vertex = int(sys.stdin.readline()) # 컴퓨터 개수 +edge = int(sys.stdin.readline()) # 연결선 개수 + +graph = [[NULL] for i in range(vertex+1)] #그래프 +visited = [0]*(vertex+1) #1번 인덱스부터 사용 + +for i in range(edge): # 그래프 생성 + a,b = map(int,stdin.split()) + graph[a]+=[b] # a 에 b 연결 + graph[b]+=[a] # b 에 a 연결 + +visited[1] = 1 # 1번 컴퓨터부터 시작이니 방문 표시 +queue = deque([1]) +while queue : + result = queue.popleft() + for i in graph[result]: + if visited[i]==0: + queue.append(i) + visited[i]=1 +print(sum(visited)-1) From 4c54f35b4d9092a8c56e60aea6ea1ca29cc8f836 Mon Sep 17 00:00:00 2001 From: Jiyun Kim Date: Wed, 17 May 2023 20:10:55 +0900 Subject: [PATCH 58/80] =?UTF-8?q?#21=20:=202606=5F=EB=B0=94=EC=9D=B4?= =?UTF-8?q?=EB=9F=AC=EC=8A=A4BFS?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...354\235\264\353\237\254\354\212\244BFS.py" | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 "\354\235\264\355\213\260\354\247\200\354\234\244/2606_\353\260\224\354\235\264\353\237\254\354\212\244BFS.py" diff --git "a/\354\235\264\355\213\260\354\247\200\354\234\244/2606_\353\260\224\354\235\264\353\237\254\354\212\244BFS.py" "b/\354\235\264\355\213\260\354\247\200\354\234\244/2606_\353\260\224\354\235\264\353\237\254\354\212\244BFS.py" new file mode 100644 index 0000000..8a7e510 --- /dev/null +++ "b/\354\235\264\355\213\260\354\247\200\354\234\244/2606_\353\260\224\354\235\264\353\237\254\354\212\244BFS.py" @@ -0,0 +1,27 @@ +import sys +from collections import deque + +N = int(sys.stdin.readline()) +C = int(sys.stdin.readline()) + +graph = [[] for i in range(N+1)] + +for i in range(C): + a, b = map(int,sys.stdin.readline().split()) + graph[a].append(b) + graph[b].append(a) + +visited = [] +def bfs(x): + q = deque([x]) + visited.append(x) + + while q: + v = q.popleft() + for i in graph[v]: + if i not in visited: + q.append(i) + visited.append(i) + +bfs(1) +print(len(visited) -1) # 1번 컴퓨터는 제외 From efb8cb1a28da844799aef52ffc7e735c562e1bb9 Mon Sep 17 00:00:00 2001 From: Jiyun Kim Date: Wed, 17 May 2023 20:13:01 +0900 Subject: [PATCH 59/80] =?UTF-8?q?#21=20:=202606=5F=EB=B0=94=EC=9D=B4?= =?UTF-8?q?=EB=9F=AC=EC=8A=A4DFS?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...354\235\264\353\237\254\354\212\244DFS.py" | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 "\354\235\264\355\213\260\354\247\200\354\234\244/2606_\353\260\224\354\235\264\353\237\254\354\212\244DFS.py" diff --git "a/\354\235\264\355\213\260\354\247\200\354\234\244/2606_\353\260\224\354\235\264\353\237\254\354\212\244DFS.py" "b/\354\235\264\355\213\260\354\247\200\354\234\244/2606_\353\260\224\354\235\264\353\237\254\354\212\244DFS.py" new file mode 100644 index 0000000..0702772 --- /dev/null +++ "b/\354\235\264\355\213\260\354\247\200\354\234\244/2606_\353\260\224\354\235\264\353\237\254\354\212\244DFS.py" @@ -0,0 +1,27 @@ +import sys + +n = int(sys.stdin.readline()) # 컴퓨터의 개수 +m = int(sys.stdin.readline()) # 쌍의 개수 + +graph = [[] for _ in range(n + 1)] + +for i in range(m): + a, b = map(int, input().split()) + graph[a].append(b) + graph[b].append(a) + +result = 0 +visited = [0] * (n + 1) + + +def dfs(start): + global result + visited[start] = 1 + for j in graph[start]: + if visited[j] == 0: + result += 1 + dfs(j) + + +dfs(1) +print(result) \ No newline at end of file From e542060c6c70e1c062ae2b2a29664e36db0d0083 Mon Sep 17 00:00:00 2001 From: yjhss <20211420.sungshin.ac.kr> Date: Wed, 17 May 2023 21:23:38 +0900 Subject: [PATCH 60/80] =?UTF-8?q?#21=20:=202606=5F=EB=B0=94=EC=9D=B4?= =?UTF-8?q?=EB=9F=AC=EC=8A=A4=5FDFS?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...54\235\264\353\237\254\354\212\244_DFS.py" | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 "\354\235\264\355\213\260\354\234\240\354\247\204/2606_\353\260\224\354\235\264\353\237\254\354\212\244_DFS.py" diff --git "a/\354\235\264\355\213\260\354\234\240\354\247\204/2606_\353\260\224\354\235\264\353\237\254\354\212\244_DFS.py" "b/\354\235\264\355\213\260\354\234\240\354\247\204/2606_\353\260\224\354\235\264\353\237\254\354\212\244_DFS.py" new file mode 100644 index 0000000..106e2c1 --- /dev/null +++ "b/\354\235\264\355\213\260\354\234\240\354\247\204/2606_\353\260\224\354\235\264\353\237\254\354\212\244_DFS.py" @@ -0,0 +1,19 @@ +import sys + +n=int(sys.stdin.readline()) +m=int(sys.stdin.readline()) +graph = [[] for i in range(n+1)] +visited=[0]*(n+1) + +for i in range(m): + a,b=map(int,input().split()) + graph[a]+=[b] + graph[b]+=[a] + +def dfs(m): + visited[m]=1 + for i in graph[m]: + if visited[i]==0: + dfs(i) +dfs(1) +print(sum(visited)-1) From 3a551e56a5f406f0fe254950f4bf3586c6dca521 Mon Sep 17 00:00:00 2001 From: yjhss <20211420.sungshin.ac.kr> Date: Wed, 17 May 2023 21:24:48 +0900 Subject: [PATCH 61/80] =?UTF-8?q?#21=20:=202606=5F=EB=B0=94=EC=9D=B4?= =?UTF-8?q?=EB=9F=AC=EC=8A=A4=5FBFS?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...54\235\264\353\237\254\354\212\244_BFS.py" | 31 +++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 "\354\235\264\355\213\260\354\234\240\354\247\204/2606_\353\260\224\354\235\264\353\237\254\354\212\244_BFS.py" diff --git "a/\354\235\264\355\213\260\354\234\240\354\247\204/2606_\353\260\224\354\235\264\353\237\254\354\212\244_BFS.py" "b/\354\235\264\355\213\260\354\234\240\354\247\204/2606_\353\260\224\354\235\264\353\237\254\354\212\244_BFS.py" new file mode 100644 index 0000000..758d0f2 --- /dev/null +++ "b/\354\235\264\355\213\260\354\234\240\354\247\204/2606_\353\260\224\354\235\264\353\237\254\354\212\244_BFS.py" @@ -0,0 +1,31 @@ +import sys +from collections import deque + +n = int(sys.stdin.readline()) +m = int(sys.stdin.readline()) +graph = [[] for i in range(n+1)] +visited = [False]*(n+1) + + +for i in range(m): + a, b = map(int, input().split()) + + graph[a].append(b) + graph[b].append(a) + +def bfs(graph, v): + cnt = 0 + queue = deque([v]) + + while queue: + pop = queue.popleft() + visited[pop] = True + + for i in graph[pop]: + if visited[i]==False: + visited[i] = True + queue.append(i) + cnt += 1 + print(cnt) + +bfs(graph, 1) \ No newline at end of file From 0d64782f7a6dc1b84f3d28a9da5a08510767aef5 Mon Sep 17 00:00:00 2001 From: jooon <98799034+SeongJoonhee@users.noreply.github.com> Date: Thu, 18 May 2023 00:49:31 +0900 Subject: [PATCH 62/80] =?UTF-8?q?#21=20:=202606=5F=EB=B0=94=EC=9D=B4?= =?UTF-8?q?=EB=9F=AC=EC=8A=A4=5FBFS?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...54\235\264\353\237\254\354\212\244_BFS.py" | 37 +++++++++++++++++++ 1 file changed, 37 insertions(+) rename "\354\235\264\355\213\260\354\244\200\355\235\254/2606_\353\260\224\354\235\264\353\237\254\354\212\244.py" => "\354\235\264\355\213\260\354\244\200\355\235\254/2606_\353\260\224\354\235\264\353\237\254\354\212\244_BFS.py" (53%) diff --git "a/\354\235\264\355\213\260\354\244\200\355\235\254/2606_\353\260\224\354\235\264\353\237\254\354\212\244.py" "b/\354\235\264\355\213\260\354\244\200\355\235\254/2606_\353\260\224\354\235\264\353\237\254\354\212\244_BFS.py" similarity index 53% rename from "\354\235\264\355\213\260\354\244\200\355\235\254/2606_\353\260\224\354\235\264\353\237\254\354\212\244.py" rename to "\354\235\264\355\213\260\354\244\200\355\235\254/2606_\353\260\224\354\235\264\353\237\254\354\212\244_BFS.py" index 228fcc9..eec5668 100644 --- "a/\354\235\264\355\213\260\354\244\200\355\235\254/2606_\353\260\224\354\235\264\353\237\254\354\212\244.py" +++ "b/\354\235\264\355\213\260\354\244\200\355\235\254/2606_\353\260\224\354\235\264\353\237\254\354\212\244_BFS.py" @@ -13,6 +13,7 @@ ''' #bfs 너비 우선 탐색 +''' import sys from collections import deque vertex = int(sys.stdin.readline()) # 컴퓨터 개수 @@ -35,3 +36,39 @@ queue.append(i) visited[i]=1 print(sum(visited)-1) +''' + +import sys +from collections import deque + +vertex = int(sys.stdin.readline()) # 컴퓨터 개수 +edge = int(sys.stdin.readline()) # 연결선 개수 + +graph = [[] for i in range(vertex + 1)] # 그래프 +visited = [0] * (vertex + 1) # 1번 인덱스부터 사용 + +for i in range(edge): # 그래프 생성 + a, b = map(int, sys.stdin.readline().split()) + graph[a].append(b) # a 에 b 연결 + graph[b].append(a) # b 에 a 연결 + + +def bfs(start): + visited[start] = 1 + queue = deque([start]) + + while queue: + node = queue.popleft() + for i in graph[node]: + if visited[i] == 0: + queue.append(i) + visited[i] = 1 + +bfs(1) # 1번 컴퓨터부터 시작 +print(sum(visited) - 1) + + + + + + From ffdac8d78959f9c1e929241a33c6d97208488eee Mon Sep 17 00:00:00 2001 From: jooon <98799034+SeongJoonhee@users.noreply.github.com> Date: Thu, 18 May 2023 00:51:26 +0900 Subject: [PATCH 63/80] =?UTF-8?q?#21=20:=202606=5F=EB=B0=94=EC=9D=B4?= =?UTF-8?q?=EB=9F=AC=EC=8A=A4=5FDFS?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...54\235\264\353\237\254\354\212\244_DFS.py" | 38 +++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 "\354\235\264\355\213\260\354\244\200\355\235\254/2606_\353\260\224\354\235\264\353\237\254\354\212\244_DFS.py" diff --git "a/\354\235\264\355\213\260\354\244\200\355\235\254/2606_\353\260\224\354\235\264\353\237\254\354\212\244_DFS.py" "b/\354\235\264\355\213\260\354\244\200\355\235\254/2606_\353\260\224\354\235\264\353\237\254\354\212\244_DFS.py" new file mode 100644 index 0000000..cce231e --- /dev/null +++ "b/\354\235\264\355\213\260\354\244\200\355\235\254/2606_\353\260\224\354\235\264\353\237\254\354\212\244_DFS.py" @@ -0,0 +1,38 @@ +#2023-05-11-Week5-과제 +#2606_바이러스 + +''' +입력 + +7 총 컴퓨터 수 +6 컴퓨터 간 연결된 선 개수 +1 2 1번컴퓨터와 2번컴퓨터 연결 +2 3 +... +4 7 +''' + +#dfs +import sys + +vertex = int(sys.stdin.readline()) # 컴퓨터 개수 +edge = int(sys.stdin.readline()) # 연결선 개수 + +graph = [[] for _ in range(vertex + 1)] # 그래프 +visited = [0] * (vertex + 1) # 1번 인덱스부터 사용 + +for i in range(edge): # 그래프 생성 + a, b = map(int, sys.stdin.readline().split()) + graph[a].append(b) # a 에 b 연결 + graph[b].append(a) # b 에 a 연결 + + +def dfs(node): + visited[node] = 1 + for i in graph[node]: + if visited[i] == 0: + dfs(i) + + +dfs(1) # 1번 컴퓨터부터 시작 +print(sum(visited) - 1) From 41c54fecf476641e8ee067d2962cd3b6a1a202f8 Mon Sep 17 00:00:00 2001 From: Jisoo Hwang <77599304+plum-king@users.noreply.github.com> Date: Sat, 20 May 2023 23:23:40 +0900 Subject: [PATCH 64/80] =?UTF-8?q?#26=20:=201753=5F=EC=B5=9C=EB=8B=A8?= =?UTF-8?q?=EA=B2=BD=EB=A1=9C.py?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...34\353\213\250\352\262\275\353\241\234.py" | 42 +++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 "\354\235\264\353\213\210\354\247\200\354\210\230/1753_\354\265\234\353\213\250\352\262\275\353\241\234.py" diff --git "a/\354\235\264\353\213\210\354\247\200\354\210\230/1753_\354\265\234\353\213\250\352\262\275\353\241\234.py" "b/\354\235\264\353\213\210\354\247\200\354\210\230/1753_\354\265\234\353\213\250\352\262\275\353\241\234.py" new file mode 100644 index 0000000..191fb49 --- /dev/null +++ "b/\354\235\264\353\213\210\354\247\200\354\210\230/1753_\354\265\234\353\213\250\352\262\275\353\241\234.py" @@ -0,0 +1,42 @@ +#1753 + +import heapq +import sys +input = sys.stdin.readline +INF = int(1e9) + + +n,m = map(int, input().split()) +start = int(input()) +graph = [[] for i in range(n+1)] +distance = [INF]*(n+1) + +for _ in range(m): + a,b,c = map(int, input().split()) + graph[a].append((b,c)) + +def dijkstra(start): + q=[] + heapq.heappush(q, (0, start)) + distance[start]=0 + + while q: + dist, now = heapq.heappop(q) + if distance[now] < dist: + continue + for i in graph[now]: + cost = dist + i[1] + if cost < distance[i[0]]: + distance[i[0]] = cost + heapq.heappush(q, (cost, i[0])) + print(q) + +dijkstra(start) + +for i in range(1, n+1): + if distance[i]==INF: + print("INF") + else: + print(distance[i]) + + From 9d52e1ccf2bc8c37e39b71ca4b2d2cdc412ce43f Mon Sep 17 00:00:00 2001 From: yjhss <20211420.sungshin.ac.kr> Date: Wed, 24 May 2023 17:07:01 +0900 Subject: [PATCH 65/80] =?UTF-8?q?#26=20:=2015723=5Fn=EB=8B=A8=20=EB=85=BC?= =?UTF-8?q?=EB=B2=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...n\353\213\250 \353\205\274\353\262\225.py" | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 "\354\235\264\355\213\260\354\234\240\354\247\204/15723_n\353\213\250 \353\205\274\353\262\225.py" diff --git "a/\354\235\264\355\213\260\354\234\240\354\247\204/15723_n\353\213\250 \353\205\274\353\262\225.py" "b/\354\235\264\355\213\260\354\234\240\354\247\204/15723_n\353\213\250 \353\205\274\353\262\225.py" new file mode 100644 index 0000000..a4398c5 --- /dev/null +++ "b/\354\235\264\355\213\260\354\234\240\354\247\204/15723_n\353\213\250 \353\205\274\353\262\225.py" @@ -0,0 +1,27 @@ +import sys + +input = sys.stdin.readline +INF = int(1e9) + +N = int(sys.stdin.readline()) + +alphabet = "abcdefghijklmnopqrstuvwxyz" +n = len(alphabet) +graph = [[INF] * n for _ in range(n)] + +for _ in range(N): + a, b = map(alphabet.index, input().rstrip().split(" is ")) + graph[a][b] = 1 + +for k in range(n): + for i in range(n): + for j in range(n): + graph[i][j] = min(graph[i][j], graph[i][k] + graph[k][j]) + +M = int(input()) +for _ in range(M): + a, b = map(alphabet.index, input().rstrip().split(" is ")) + if graph[a][b] == INF: + print("F") + else: + print("T") From 1c33649b3638390a3ebcbfcc6e6547ab1f549a8b Mon Sep 17 00:00:00 2001 From: yjhss <20211420.sungshin.ac.kr> Date: Wed, 24 May 2023 17:30:04 +0900 Subject: [PATCH 66/80] =?UTF-8?q?#26=20:=2010026=5F=EC=A0=81=EB=A1=9D?= =?UTF-8?q?=EC=83=89=EC=95=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...01\353\241\235\354\203\211\354\225\275.py" | 44 +++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 "\354\235\264\355\213\260\354\234\240\354\247\204/10026_\354\240\201\353\241\235\354\203\211\354\225\275.py" diff --git "a/\354\235\264\355\213\260\354\234\240\354\247\204/10026_\354\240\201\353\241\235\354\203\211\354\225\275.py" "b/\354\235\264\355\213\260\354\234\240\354\247\204/10026_\354\240\201\353\241\235\354\203\211\354\225\275.py" new file mode 100644 index 0000000..b8e1f30 --- /dev/null +++ "b/\354\235\264\355\213\260\354\234\240\354\247\204/10026_\354\240\201\353\241\235\354\203\211\354\225\275.py" @@ -0,0 +1,44 @@ +import sys +from collections import deque + +n = int(sys.stdin.readline()) +visited = [[False] * n for _ in range(n)] +grid = [list(map(str, input())) for _ in range(n)] +queue = deque() + +dx = [-1, 1, 0, 0] +dy = [0, 0, -1, 1] + +def bfs(x, y): + queue.append([x, y]) + while queue: + x, y = queue.popleft() + for i in range(4): + nx = x + dx[i] + ny = y + dy[i] + if 0 <= nx < n and 0 <= ny < n and not visited[nx][ny] and grid[nx][ny] == grid[x][y]: + queue.append([nx, ny]) + visited[nx][ny] = True + +count = 0 +for i in range(n): + for j in range(n): + if not visited[i][j]: + bfs(i, j) + count += 1 +print(count, end=' ') + +for i in range(n): + for j in range(n): + if grid[i][j] == 'R': + grid[i][j] = 'G' + +visited = [[False] * n for _ in range(n)] + +count = 0 +for i in range(n): + for j in range(n): + if not visited[i][j]: + bfs(i, j) + count += 1 +print(count) \ No newline at end of file From 29ea48926977374fb6fabf31dea1f53999a6660d Mon Sep 17 00:00:00 2001 From: Jiyun Kim Date: Wed, 24 May 2023 22:01:58 +0900 Subject: [PATCH 67/80] =?UTF-8?q?#26=20:=2015723=5Fn=EB=8B=A8=20=EB=85=BC?= =?UTF-8?q?=EB=B2=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...n\353\213\250 \353\205\274\353\262\225.py" | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 "\354\235\264\355\213\260\354\247\200\354\234\244/15723_n\353\213\250 \353\205\274\353\262\225.py" diff --git "a/\354\235\264\355\213\260\354\247\200\354\234\244/15723_n\353\213\250 \353\205\274\353\262\225.py" "b/\354\235\264\355\213\260\354\247\200\354\234\244/15723_n\353\213\250 \353\205\274\353\262\225.py" new file mode 100644 index 0000000..616e873 --- /dev/null +++ "b/\354\235\264\355\213\260\354\247\200\354\234\244/15723_n\353\213\250 \353\205\274\353\262\225.py" @@ -0,0 +1,29 @@ +import sys + +input = sys.stdin.readline +INF = int(1e9) # 무한을 의미하는 값으로 10억 + +N = int(input()) + +alphabet = "abcdefghijklmnopqrstuvwxyz" + +n = len(alphabet) #26 + +graph = [[INF] * n for _ in range(n)] # INF로 초기화 + +for _ in range(N): + a, b = map(alphabet.index, input().rstrip().split(" is ")) + graph[a][b] = 1 + +for k in range(n): + for a in range(n): + for b in range(n): + graph[a][b] = min(graph[a][b], graph[a][k] + graph[k][b]) + +M = int(input()) +for _ in range(M): + a, b = map(alphabet.index, input().rstrip().split(" is ")) + if graph[a][b] == INF: + print("F") + else: + print("T") From 24123db7288cb28b39838a523d79638408a7b718 Mon Sep 17 00:00:00 2001 From: Jiyun Kim Date: Wed, 24 May 2023 22:02:52 +0900 Subject: [PATCH 68/80] =?UTF-8?q?#26=20:=2010026=5F=EC=A0=81=EB=A1=9D?= =?UTF-8?q?=EC=83=89=EC=95=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...01\353\241\235\354\203\211\354\225\275.py" | 71 +++++++++++++++++++ 1 file changed, 71 insertions(+) create mode 100644 "\354\235\264\355\213\260\354\247\200\354\234\244/10026_\354\240\201\353\241\235\354\203\211\354\225\275.py" diff --git "a/\354\235\264\355\213\260\354\247\200\354\234\244/10026_\354\240\201\353\241\235\354\203\211\354\225\275.py" "b/\354\235\264\355\213\260\354\247\200\354\234\244/10026_\354\240\201\353\241\235\354\203\211\354\225\275.py" new file mode 100644 index 0000000..786a158 --- /dev/null +++ "b/\354\235\264\355\213\260\354\247\200\354\234\244/10026_\354\240\201\353\241\235\354\203\211\354\225\275.py" @@ -0,0 +1,71 @@ +#10026_적록색약 +#적록색약이 아닌 사람 : 유기농 배추랑 똑같음 +#적록색약인 사람 : +import sys +sys.setrecursionlimit(10000) + +read=sys.stdin.readline +#MAX= 100+10 +#print(MAX) +n = int(read()) + +#인덱스0부터 3까지 차례대로 합치면 오른쪽, 왼쪽, 위, 아래 +dirX = [1, -1, 0, 0] +dirY = [0, 0, 1, -1] + +graph +graph = [list(input().rstrip()) for _ in range(n+1)] + +#graph = [[]] # 인덱스 0은 빈 리스트로 초기화 + +# for _ in range(n): +# line = list(input().rstrip()) +# graph.append(line) + +# graph = [[]] +# for i in range(n): +# graph.append(list(sys.stdin.readline().rstrip())) + +#visited +visited=[[False]*(n+1) for _ in range(n+1)] + +count1 = 0 +count2 = 0 + + +def dfs(x,y): + global graph, visited + visited[x][y] = True + + for i in range(4): + newX = x + dirX[i] + newY = y + dirY[i] + if not visited[newX][newY]: + if graph[newX][newY] == graph[x][y]:#위 조건 만족하면서 탐색중인 색상과 같은 색이면 + dfs(newX, newY) #dfs로 탐색 + +# 적녹색약이 아닌 사람 +for i in range(1, n+1): + for j in range(1, n+1): + if graph[i][j] and not visited[i][j]: + dfs(i, j) + count1 += 1 + +# 적녹색약인 사람 +# 초록색->빨간색으로 변경 +for i in range(1, n+1): + for j in range(1, n+1): + if graph[i][j] == 'G': + graph[i][j] = 'R' +# 방문정보 초기화 +visited = [[False]*(n+1) for _ in range(n+1)] +for i in range(1, n+1): + for j in range(1, n+1): + if graph[i][j] and not visited[i][j]: + dfs(i, j) + count2 += 1 + +print(count1, count2) + + + From f6a3c54d3330eaa01b190d0cfd9644140896ebc0 Mon Sep 17 00:00:00 2001 From: Sung-won Yang <86403488+Suanna01@users.noreply.github.com> Date: Thu, 25 May 2023 13:59:14 +0900 Subject: [PATCH 69/80] Update README.md --- README.md | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 92fe889..b36b56a 100644 --- a/README.md +++ b/README.md @@ -42,37 +42,37 @@
❤️성원이니❤️
-

+

🧡지수이니🧡
-

+

💛지우이니💛
-

+

💚예원이티💚
-

+

💙유진이티💙
-

+

💜준희이티💜
-

+

🖤지윤이티🖤
-

+

From 598478c7e28383d92bf7675c7a38e3f5d58eb100 Mon Sep 17 00:00:00 2001 From: plum-king Date: Sat, 27 May 2023 11:01:58 +0900 Subject: [PATCH 70/80] =?UTF-8?q?#31=20:=20=ED=94=84=EB=A1=9C=EA=B7=B8?= =?UTF-8?q?=EB=9E=98=EB=A8=B8=EC=8A=A4=5F=EC=84=AC=20=EC=97=B0=EA=B2=B0?= =?UTF-8?q?=ED=95=98=EA=B8=B0.py?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...60\352\262\260\355\225\230\352\270\260.py" | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 "\354\235\264\353\213\210\354\247\200\354\210\230/\354\204\254 \354\227\260\352\262\260\355\225\230\352\270\260.py" diff --git "a/\354\235\264\353\213\210\354\247\200\354\210\230/\354\204\254 \354\227\260\352\262\260\355\225\230\352\270\260.py" "b/\354\235\264\353\213\210\354\247\200\354\210\230/\354\204\254 \354\227\260\352\262\260\355\225\230\352\270\260.py" new file mode 100644 index 0000000..b57a025 --- /dev/null +++ "b/\354\235\264\353\213\210\354\247\200\354\210\230/\354\204\254 \354\227\260\352\262\260\355\225\230\352\270\260.py" @@ -0,0 +1,26 @@ +parent=[] + +def find(parent,x): + if(parent[x]==x): + return x + return find(parent,parent[x]) + +def union(parent,a,b): + rootA=find(parent,a) + rootB=find(parent,b) + if(rootA Date: Wed, 31 May 2023 19:12:31 +0900 Subject: [PATCH 71/80] =?UTF-8?q?#26=20:=2010026=5F=EC=A0=81=EB=A1=9D?= =?UTF-8?q?=EC=83=89=EC=95=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...01\353\241\235\354\203\211\354\225\275.py" | 41 ++++++++----------- 1 file changed, 16 insertions(+), 25 deletions(-) diff --git "a/\354\235\264\355\213\260\354\247\200\354\234\244/10026_\354\240\201\353\241\235\354\203\211\354\225\275.py" "b/\354\235\264\355\213\260\354\247\200\354\234\244/10026_\354\240\201\353\241\235\354\203\211\354\225\275.py" index 786a158..30d320b 100644 --- "a/\354\235\264\355\213\260\354\247\200\354\234\244/10026_\354\240\201\353\241\235\354\203\211\354\225\275.py" +++ "b/\354\235\264\355\213\260\354\247\200\354\234\244/10026_\354\240\201\353\241\235\354\203\211\354\225\275.py" @@ -13,21 +13,11 @@ dirX = [1, -1, 0, 0] dirY = [0, 0, 1, -1] -graph -graph = [list(input().rstrip()) for _ in range(n+1)] - -#graph = [[]] # 인덱스 0은 빈 리스트로 초기화 - -# for _ in range(n): -# line = list(input().rstrip()) -# graph.append(line) - -# graph = [[]] -# for i in range(n): -# graph.append(list(sys.stdin.readline().rstrip())) +#graph +graph = [list(input().rstrip()) for _ in range(n)] #visited -visited=[[False]*(n+1) for _ in range(n+1)] +visited=[[False]*(n) for _ in range(n)] count1 = 0 count2 = 0 @@ -40,27 +30,28 @@ def dfs(x,y): for i in range(4): newX = x + dirX[i] newY = y + dirY[i] - if not visited[newX][newY]: - if graph[newX][newY] == graph[x][y]:#위 조건 만족하면서 탐색중인 색상과 같은 색이면 - dfs(newX, newY) #dfs로 탐색 + if (n > newX >= 0) and (n > newY >= 0): + if not visited[newX][newY]: + if graph[newX][newY] == graph[x][y]:#위 조건 만족하면서 탐색중인 색상과 같은 색이면 + dfs(newX, newY) #dfs로 탐색 # 적녹색약이 아닌 사람 -for i in range(1, n+1): - for j in range(1, n+1): +for i in range(0, n): + for j in range(0, n): if graph[i][j] and not visited[i][j]: dfs(i, j) count1 += 1 # 적녹색약인 사람 # 초록색->빨간색으로 변경 -for i in range(1, n+1): - for j in range(1, n+1): - if graph[i][j] == 'G': - graph[i][j] = 'R' +for i in range(0, n): + for j in range(0, n): + if graph[i][j] == 'R': + graph[i][j] = 'G' # 방문정보 초기화 -visited = [[False]*(n+1) for _ in range(n+1)] -for i in range(1, n+1): - for j in range(1, n+1): +visited = [[False]*(n) for _ in range(n)] +for i in range(0, n): + for j in range(0, n): if graph[i][j] and not visited[i][j]: dfs(i, j) count2 += 1 From 85842f752a7003baa9f085ca780a6d73ab4d0ba8 Mon Sep 17 00:00:00 2001 From: Jiyun Kim Date: Wed, 31 May 2023 19:13:36 +0900 Subject: [PATCH 72/80] =?UTF-8?q?#31=20:=201931=5F=ED=9A=8C=EC=9D=98?= =?UTF-8?q?=EC=8B=A4=20=EB=B0=B0=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...0\354\213\244 \353\260\260\354\240\225.py" | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 "\354\235\264\355\213\260\354\247\200\354\234\244/1931_\355\232\214\354\235\230\354\213\244 \353\260\260\354\240\225.py" diff --git "a/\354\235\264\355\213\260\354\247\200\354\234\244/1931_\355\232\214\354\235\230\354\213\244 \353\260\260\354\240\225.py" "b/\354\235\264\355\213\260\354\247\200\354\234\244/1931_\355\232\214\354\235\230\354\213\244 \353\260\260\354\240\225.py" new file mode 100644 index 0000000..e137614 --- /dev/null +++ "b/\354\235\264\355\213\260\354\247\200\354\234\244/1931_\355\232\214\354\235\230\354\213\244 \353\260\260\354\240\225.py" @@ -0,0 +1,32 @@ +# 1931_회의실 배정 + +import sys + +# 회의의 수 +n = int(sys.stdin.readline()) + +# 회의 시간 +meeting_times = [] + +# 회의의 시작 시간과 끝나는 시간 +for _ in range(n): + start, end = map(int, sys.stdin.readline().split()) + meeting_times.append((start, end)) + +# 회의 시간을 종료 시간 기준 및 시작 시간 기준으로 정렬 +meeting_times = sorted(meeting_times, key = lambda x : (x[1], x[0])) + +# 최대 회의 개수 +count = 1 +# 이전 회의 종료 시간 +end_time = meeting_times[0][1] + +for i in range(1, n): + # 다음 회의 시작 시간이 이전 회의 종료 시간보다 크거나 같다면 + if (meeting_times[i][0] >= end_time): + # 이전 회의 종료 시간 업데이트 + end_time = meeting_times[i][1] + # 최대 회의 개수 증가 + count += 1 + +print(count) \ No newline at end of file From e2e289e72b8240f1b8f790e72a8b6bd008e18472 Mon Sep 17 00:00:00 2001 From: Jiyun Kim Date: Wed, 31 May 2023 19:13:54 +0900 Subject: [PATCH 73/80] =?UTF-8?q?#31=20:=201654=5F=EB=9E=9C=EC=84=A0=20?= =?UTF-8?q?=EC=9E=90=EB=A5=B4=EA=B8=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...0 \354\236\220\353\245\264\352\270\260.py" | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 "\354\235\264\355\213\260\354\247\200\354\234\244/1654_\353\236\234\354\204\240 \354\236\220\353\245\264\352\270\260.py" diff --git "a/\354\235\264\355\213\260\354\247\200\354\234\244/1654_\353\236\234\354\204\240 \354\236\220\353\245\264\352\270\260.py" "b/\354\235\264\355\213\260\354\247\200\354\234\244/1654_\353\236\234\354\204\240 \354\236\220\353\245\264\352\270\260.py" new file mode 100644 index 0000000..a1e941b --- /dev/null +++ "b/\354\235\264\355\213\260\354\247\200\354\234\244/1654_\353\236\234\354\204\240 \354\236\220\353\245\264\352\270\260.py" @@ -0,0 +1,24 @@ +import sys + +input = sys.stdin.readline + +# k : 이미 가지고 있는 랜선의 개수, n : 필요한 랜선의 개수 +k, n = map(int, input().split()) +lan = [int(input()) for _ in range(k)] + +answer = 0 # 랜선의 최대 길이 + +start, end = 1, max(lan) +while start <= end: + mid = (start + end) // 2 + temp_sum = 0 + for i in lan: # mid 길이만큼 랜선 케이블들을 조각냄 + temp_sum += i // mid + + if temp_sum >= n: # 랜선의 개수가 n이상이면 + start = mid + 1 + answer = mid + else: # 랜선의 개수가 n미만이면 + end = mid - 1 + +print(answer) \ No newline at end of file From fd7635aae865a150015ce587a0c87d0f3bb88376 Mon Sep 17 00:00:00 2001 From: yjhss <20211420.sungshin.ac.kr> Date: Wed, 31 May 2023 21:58:04 +0900 Subject: [PATCH 74/80] =?UTF-8?q?#31=20:=201654=5F=EB=9E=9C=EC=84=A0=20?= =?UTF-8?q?=EC=9E=90=EB=A5=B4=EA=B8=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...0 \354\236\220\353\245\264\352\270\260.py" | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 "\354\235\264\355\213\260\354\234\240\354\247\204/1654_\353\236\234\354\204\240 \354\236\220\353\245\264\352\270\260.py" diff --git "a/\354\235\264\355\213\260\354\234\240\354\247\204/1654_\353\236\234\354\204\240 \354\236\220\353\245\264\352\270\260.py" "b/\354\235\264\355\213\260\354\234\240\354\247\204/1654_\353\236\234\354\204\240 \354\236\220\353\245\264\352\270\260.py" new file mode 100644 index 0000000..088bb77 --- /dev/null +++ "b/\354\235\264\355\213\260\354\234\240\354\247\204/1654_\353\236\234\354\204\240 \354\236\220\353\245\264\352\270\260.py" @@ -0,0 +1,26 @@ +import sys + +K, N = map(int, input().split()) + +lan = [int(sys.stdin.readline()) for _ in range(K)] + +def binary_search(start, end, N): + start = 1 + end = max(lan) + + while start <= end: + mid = (start + end) // 2 + + lines = [(i//mid) for i in lan] + + + if lines == N: + return mid + elif lines < N: + start = mid + 1 + else: + end = mid - 1 + + print(end) + +binary_search(lan, N) \ No newline at end of file From 457066163d84e79b04e87358a86f935bf0cd480c Mon Sep 17 00:00:00 2001 From: yjhss <20211420.sungshin.ac.kr> Date: Wed, 31 May 2023 21:58:26 +0900 Subject: [PATCH 75/80] =?UTF-8?q?#31=20:=201931=5F=ED=9A=8C=EC=9D=98?= =?UTF-8?q?=EC=8B=A4=20=EB=B0=B0=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...0\354\213\244 \353\260\260\354\240\225.py" | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 "\354\235\264\355\213\260\354\234\240\354\247\204/1931_\355\232\214\354\235\230\354\213\244 \353\260\260\354\240\225.py" diff --git "a/\354\235\264\355\213\260\354\234\240\354\247\204/1931_\355\232\214\354\235\230\354\213\244 \353\260\260\354\240\225.py" "b/\354\235\264\355\213\260\354\234\240\354\247\204/1931_\355\232\214\354\235\230\354\213\244 \353\260\260\354\240\225.py" new file mode 100644 index 0000000..7870a03 --- /dev/null +++ "b/\354\235\264\355\213\260\354\234\240\354\247\204/1931_\355\232\214\354\235\230\354\213\244 \353\260\260\354\240\225.py" @@ -0,0 +1,19 @@ +import sys +N = int(sys.stdin.readline()) + +meetings = [] + +for _ in range(N): + start, end = map(int, input().split(" ")) + meetings.append((start, end)) + +meetings.sort(key=lambda x: (x[1], x[0])) + +time = 0 +cnt = 0 +for i in meetings: + if time <= i[0]: + time = i[1] + cnt += 1 + +print(cnt) \ No newline at end of file From 1b6f0395834101fd915565e21851ea41254b87fd Mon Sep 17 00:00:00 2001 From: Sung-won Yang <86403488+Suanna01@users.noreply.github.com> Date: Sat, 3 Jun 2023 09:18:54 +0900 Subject: [PATCH 76/80] Update README.md --- README.md | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index b36b56a..fc8e17c 100644 --- a/README.md +++ b/README.md @@ -42,37 +42,37 @@
❤️성원이니❤️
-

+

🧡지수이니🧡
-

+

💛지우이니💛
-

+

💚예원이티💚
-

+

💙유진이티💙
-

+

💜준희이티💜
-

+

🖤지윤이티🖤
-

+

From 5a838f2046b899015eddde5311e4177189141ea1 Mon Sep 17 00:00:00 2001 From: Sung-won Yang <86403488+Suanna01@users.noreply.github.com> Date: Tue, 6 Jun 2023 00:35:26 +0900 Subject: [PATCH 77/80] Update README.md --- README.md | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index fc8e17c..51cb776 100644 --- a/README.md +++ b/README.md @@ -42,37 +42,37 @@
❤️성원이니❤️
-

+

🧡지수이니🧡
-

+

💛지우이니💛
-

+

💚예원이티💚
-

+

💙유진이티💙
-

+

💜준희이티💜
-

+

🖤지윤이티🖤
-

+

From c9e5cd3a775f2d6643c9d7a4e8321dad408e80b0 Mon Sep 17 00:00:00 2001 From: Jisoo Hwang <77599304+plum-king@users.noreply.github.com> Date: Fri, 9 Jun 2023 23:36:00 +0900 Subject: [PATCH 78/80] Update README.md --- README.md | 1 - 1 file changed, 1 deletion(-) diff --git a/README.md b/README.md index 51cb776..869af21 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,3 @@ -![image](https://user-images.githubusercontent.com/86403488/227709165-3b211671-4642-4186-abfa-fb4ae5b4a52f.png) # 알고리즘 문제 풀기 💯 성신여대 컴퓨터공학과 과동아리 INIT의 알고리즘 스터디입니다. From 0249053233b3f872919adad7e71f75e1cc98a97b Mon Sep 17 00:00:00 2001 From: yjhss <20211420.sungshin.ac.kr> Date: Mon, 12 Jun 2023 11:07:22 +0900 Subject: [PATCH 79/80] =?UTF-8?q?#31=20:=201654=5F=EB=9E=9C=EC=84=A0=20?= =?UTF-8?q?=EC=9E=90=EB=A5=B4=EA=B8=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...0 \354\236\220\353\245\264\352\270\260.py" | 28 ++++++++----------- 1 file changed, 12 insertions(+), 16 deletions(-) diff --git "a/\354\235\264\355\213\260\354\234\240\354\247\204/1654_\353\236\234\354\204\240 \354\236\220\353\245\264\352\270\260.py" "b/\354\235\264\355\213\260\354\234\240\354\247\204/1654_\353\236\234\354\204\240 \354\236\220\353\245\264\352\270\260.py" index 088bb77..f05b0c8 100644 --- "a/\354\235\264\355\213\260\354\234\240\354\247\204/1654_\353\236\234\354\204\240 \354\236\220\353\245\264\352\270\260.py" +++ "b/\354\235\264\355\213\260\354\234\240\354\247\204/1654_\353\236\234\354\204\240 \354\236\220\353\245\264\352\270\260.py" @@ -5,22 +5,18 @@ lan = [int(sys.stdin.readline()) for _ in range(K)] def binary_search(start, end, N): - start = 1 - end = max(lan) - - while start <= end: - mid = (start + end) // 2 + result = 0 + while start <= end: + mid = (start + end) // 2 + lines = sum([(i // mid) for i in lan]) - lines = [(i//mid) for i in lan] - - - if lines == N: - return mid - elif lines < N: - start = mid + 1 - else: - end = mid - 1 + if lines >= N: + result = mid + start = mid + 1 + else: + end = mid - 1 - print(end) + return result -binary_search(lan, N) \ No newline at end of file +answer = binary_search(1, max(lan), N) +print(answer) \ No newline at end of file From 7b38b97b57de6c60f48acd7f60315864fa5bd3da Mon Sep 17 00:00:00 2001 From: Sung-won Yang <86403488+Suanna01@users.noreply.github.com> Date: Fri, 16 Jun 2023 11:51:26 +0900 Subject: [PATCH 80/80] Update README.md --- README.md | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 869af21..15939cc 100644 --- a/README.md +++ b/README.md @@ -41,37 +41,37 @@
❤️성원이니❤️
-

+

🧡지수이니🧡
-

+

💛지우이니💛
-

+

💚예원이티💚
-

+

💙유진이티💙
-

+

💜준희이티💜
-

+

🖤지윤이티🖤
-

+