본문 바로가기

python-algorithm1422

백준 17903 Counting Clauses https://www.acmicpc.net/problem/17903 17903번: Counting Clauses The input is a single instance of the 3-SAT problem. The first line is two space-separated integers: m (1 ≤ m ≤ 20), the number of clauses and n (3 ≤ n ≤ 20), the number of variables. Then m clauses follow, one clause per line. Each clause consists www.acmicpc.net 1 2 3 m, n = map(int, input().split()) print("satisfactory" if m >= 8 .. 2022. 11. 30.
백준 3060 욕심쟁이 돼지 https://www.acmicpc.net/problem/3060 3060번: 욕심쟁이 돼지 입력은 T개의 테스트 데이터로 구성된다. 입력의 첫 번째 줄에는 입력 데이터의 수를 나타내는 정수 T가 주어진다. 각 테스트 데이터는 두 줄로 구성되어 있고, 첫째 줄에는 하루에 배달되는 사 www.acmicpc.net 1 2 3 4 5 6 7 8 9 10 11 12 13 14 def sol(food, pigs): total_sum =sum(pigs) days = 1 while food>=total_sum: total_sum+=total_sum*3 days+=1 return days if __name__ == '__main__': n=int(input()) for i in range(n): food = int(i.. 2022. 11. 30.
백준 25915 연세여 사랑한다 https://www.acmicpc.net/problem/25915 25915번: 연세여 사랑한다 훈규가 비밀번호를 모두 입력하기 위한 이동 거리의 최솟값을 출력한다. www.acmicpc.net 1 2 3 4 5 6 7 8 9 10 11 def sol(c, yonsei): answer = 0 yonsei.insert(0,c) for i in range(1,len(yonsei)): answer+=abs(ord(yonsei[i])-ord(yonsei[i-1])) return answer if __name__ == '__main__': c =input() yonsei = (list('ILOVEYONSEI')) print(sol(c,yonsei)) cs 2022. 11. 30.
백준 15372 A Simple Problem. https://www.acmicpc.net/problem/15372 15372번: A Simple Problem. For each test case, output a single line containing the integer K, the answer for that test case. www.acmicpc.net 1 2 3 4 5 6 7 8 9 import sys def sol(n): return n*n if __name__ == '__main__': t = int(input()) for _ in range(t): n = int(sys.stdin.readline()) print(sol(n)) cs sys.stdin.readline() 입력 받으셔야 시간초과 안떠요 2022. 11. 30.
백준 13623 Zero or One https://www.acmicpc.net/problem/13623 13623번: Zero or One Everyone probably knows the game Zero or One (in some regions in Brazil also known as Two or One), used to determine a winner among three or more players. For those unfamiliar, the game works as follows. Each player chooses a value between zero or one; pro www.acmicpc.net 1 2 3 4 5 6 7 8 9 10 11 12 13 def sol(a,b,c): answer = '*' if a!=b .. 2022. 11. 30.
백준 25600 Triathlon https://www.acmicpc.net/problem/25600 25600번: Triathlon 트라이애슬론(Triathlon)이란 라틴어에서 $3$가지라는 의미를 가진 tri와 경기를 뜻하는 athlon의 합성어이다. 우리나라에서는 트라이애슬론 대신 철인 3종 경기로 알려져 있다. 트라이애슬론은 여러 www.acmicpc.net 1 2 3 4 5 6 7 8 9 10 if __name__ == '__main__': scores =[] n = int(input()) for _ in range(n): a,d,g=map(int,input().split()) score = a*(d+g) if a == (d+g): score*=2 scores.append(score) print(max(scores)) cs 2022. 11. 29.
백준 25881 Electric Bill https://www.acmicpc.net/problem/25881 25881번: Electric Bill The first input line contains two integers (each between 2 and 20, inclusive), indicating the rate/KWH for the first 1000 KWH and the rate/KWH for the additional usage, respectively. The next input line contains a positive integer, n, indicating the number www.acmicpc.net 1 2 3 4 5 6 7 if __name__ == '__main__': first_price, second_pric.. 2022. 11. 29.
백준 25983 Majestic 10 https://www.acmicpc.net/problem/25893 25893번: Majestic 10 The movie “Magnificent 7” has become a western classic. Well, this year we have 10 coaches training the UCF programming teams and once you meet them, you’ll realize why they are called the “Majestic 10”! The number 10 is actually special in many www.acmicpc.net 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 def sol(nums): tri.. 2022. 11. 29.
백준 25858 Divide the Cash https://www.acmicpc.net/problem/25858 25858번: Divide the Cash The UCF Programming Team coaches schedule practices regularly in fall and spring (by the way, all UCF students are welcome to the practices). During summer, the majority of the team members are gone but the coaches know how to make sure the students don’ www.acmicpc.net 1 2 3 4 5 6 7 8 if __name__ == '__main__': n_students, total_priz.. 2022. 11. 29.
백준 25991 Lots of Liquid https://www.acmicpc.net/problem/25991 25991번: Lots of Liquid You work at a warehouse that sells chemical products, where somebody just placed an order for all the Boron Acetate Phosphoric Carbonate (BAPC) that you have in store. This liquid is stored in many separate lots, in cube-shaped containers, but your client www.acmicpc.net 1 2 3 4 5 6 7 8 9 10 11 def sol(liquids): total = 0 for i in liqu.. 2022. 11. 29.
백준 26068 치킨댄스를 추는 곰곰이를 본 임스 2 https://www.acmicpc.net/problem/26068 26068번: 치킨댄스를 추는 곰곰이를 본 임스 2 첫 번째 줄에는 임스가 받은 기프티콘의 개수 정수 $N$이 주어진다. ($1 \le N \le 1\,000$) 두 번째 줄부터 $N$개의 줄에 걸쳐 $i$번째 기프티콘의 남은 유효기간 $x_i$가 D-xi 와 같은 형식으로 주어진다. ( www.acmicpc.net 1 2 3 4 5 6 7 8 if __name__ == '__main__': n =int(input()) answer = 0 for _ in range(n): gifticon = input() if int(gifticon[2:]) 2022. 11. 29.
백준 11586 지영 공주님의 마법 거울 https://www.acmicpc.net/problem/11586 11586번: 지영 공주님의 마법 거울 천나라 민호성의 지영 공주님은 매우 아름답다. 공주님 자신도 이 세상 그 누구보다 자신이 아름답다는 것을 알고 있다. 공주님은 자신의 아름다움이 세월의 저편으로 사라지는 것을 매우 두려 www.acmicpc.net 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 def sol(mirror, k): if k == 1: for i in mirror: print(i) elif k == 2: for i in mirror: print(i[::-1]) elif k == 3: for i in range(1,len(mirror)+1): print(mirror[-i]) r.. 2022. 11. 29.