python-algorithm1422 백준 4589 Gnome Sequencing 1 2 3 4 5 6 7 8 9 10 11 12 def sol(nums): ans =False if nums==sorted(nums) or nums==sorted(nums,reverse=True) : ans=True return ans print("Gnomes:") for i in range(int(input())): nums=list(map(int,input().split())) if sol(nums)== True: print("Ordered") else : print("Unordered") Colored by Color Scripter cs 2022. 8. 2. 백준 4696 St. Ives 1 2 3 4 5 6 7 8 9 10 11 def sol(n): ans=0 for i in range(5): ans += n**i return ans while 1: n=float(input()) if n==0 : break print("%.2f"%sol(n)) cs 2022. 8. 2. codeforces 200B - Drinks 1 2 3 4 5 def sol(n,nums): return 100*sum(nums)/(n*100) n=int(input()) nums=list(map(int,input().split())) print(sol(n,nums)) cs 2022. 7. 20. leetcode 1702A - Round Down the Price + 1 2 3 4 5 def sol(n): n_len=len(str(n)) return n-10**(n_len-1) for i in range(int(input())): print(sol(int(input()))) cs 2022. 7. 19. leetcode 1702B - Polycarp Writes a String from Memory 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 def sol(s): cnt=0 days=1 string_list = [] for i in s: if i in string_list: pass else : if cnt>=3: cnt=0 days+=1 string_list = [] string_list.append(i) cnt+=1 return days for i in range(int(input())): print(sol(input())) cs 2022. 7. 19. codeforces 791A - Bear and Big Brother 1 2 3 4 5 6 7 8 9 def sol(a,b): cnt=0 while a 2022. 7. 12. leetcode 2022. Convert 1D Array Into 2D Array 1 2 3 4 5 6 7 8 9 10 11 12 13 class Solution: def construct2DArray(self, original: List[int], m: int, n: int) -> List[List[int]]: output=[] n_original=len(original) if n_original/m != n : return output else : for i in range(m): tmp_list=[] for j in range(n): tmp_list.append(original[n*i+j]) output.append(tmp_list) return output Colored by Color Scripter cs 2022. 7. 11. leetcode 2215. Find the Difference of Two Arrays 1 2 3 4 5 6 7 8 9 10 11 12 13 14 pythoclass Solution: def findDifference(self, nums1: List[int], nums2: List[int]) -> List[List[int]]: ans1=[] ans2=[] ans_list=[] for i in nums1 : if i not in nums2: ans1.append(i) for i in nums2 : if i not in nums1: ans2.append(i) ans_list.append(list(set(ans1))) ans_list.append(list(set(ans2))) return ans_list Colored by Color Scripter cs 2022. 7. 8. leetcode 2303. Calculate Amount Paid in Taxes 1 2 3 4 5 6 7 8 9 10 11 12 13 14 class Solution: def calculateTax(self, brackets: List[List[int]], income: int) -> float: upper= min(brackets[0][0],income) rate=brackets[0][1] answer = upper * rate / 100 income-=upper for i in range(1,len(brackets)): if income 2022. 7. 7. leetcode 1945. Sum of Digits of String After Convert 1 2 3 4 5 6 7 8 9 10 11 12 13 class Solution: def getLucky(self, s: str, k: int) -> int: str_num='' for i in s: str_num+=str(ord(i)-96) int_num=0 for _ in range(k): for i in str_num: int_num+=int(i) str_num=str(int_num) int_num=0 return(int(str_num)) cs 2022. 7. 7. 백준 25305 커트라인 1 2 3 4 5 6 7 def sol(nums,k): nums.sort(reverse=True) print(nums[k - 1]) n,k=map(int, input().split()) nums=list(map(int, input().split())) sol(nums,k) cs 2022. 7. 7. leetcode 2236. Root Equals Sum of Children 1 2 3 4 5 6 7 8 9 10 11 12 # Definition for a binary tree node. # class TreeNode: # def __init__(self, val=0, left=None, right=None): # self.val = val # self.left = left # self.right = right class Solution: def checkTree(self, root: Optional[TreeNode]) -> bool: if root.val == root.left.val+root.right.val : return True else : return False Colored by Color Scripter cs 2022. 7. 7. 이전 1 ··· 39 40 41 42 43 44 45 ··· 119 다음