분류 전체보기
-
알고리즘 & 자료구조 스터디(10조) 2일차알고리즘 2023. 5. 23. 20:57
Q1011 달나라 여행 이게 왜 안되는지는 의문이여서 구글링 좀 참고했지만 내가 왜 안됬는지 모르기 때문에 나중에 물어봐야지 def spaceShip(x, y): distance = y - x try: if distance == 1: return 1 elif distance == 2: return 2 elif distance == 3: return 3 else: raise Exception("") except Exception: num1 = distance ** (1/2) num2 = int(distance ** (1/2)) if num1 == num2: return num2 + (num2 -1) # (distance * 2) - 1 else: num3 = 0 for i in range(1, num2 +..
-
알고리즘 & 자료구조 스터디(10조) 1일차알고리즘 2023. 5. 23. 15:09
Q.4948 베르트랑 공준 - 소수인지 아닌지를 구하는 함수를 적용시켜서 구해보았지만 정답이 아니다 수정을 좀 더 진행 한 후 안되면 어쩔 수 없지... def sosu(x): for i in range(2, x): if x % i == 0: return False return True x = int(input()) count = 0 for i in range(x, (2 * x) + 1): if sosu(i): count += 1 print(count) Q.2869 달팽이는 올라가고 싶다 - 시간초과라고 하는데 줄여봐야겠다. 반복문 아니라 다른 것을 이용하는 지 고민이 된다. x, y, z = map(int, input().split()) start = 0 count = 0 while True: star..
-
즐거운 자바 -부부개발단 [인프런] Day-1프로그래밍 언어/Java 2023. 5. 18. 18:28
수강 내용 : 강의 섹션 0 ~ 1 키워드란? 프라이미티브 타입 VS 레퍼런스 타입 byte 크기를 통한 자료구조 && VS & 조건문과 삼항연산자 반복문과 라벨을 통한 break 키워드란? 자바에서 미리 만든 예약어로써 변수 선언 시에 변수 앞에 쓰이는 것 int i = 1; 에서 int => 정수 키워드 Book b = new Book(); 키워드가 Book으로 쓰였다고 생각되며 이때 참조형 자료형(래퍼런스 타입)의 카워드가 사용 되었다고 생각 && vS & 앞의 항이 false 이면 뒤에 위치한 항은 실행하지 않음 => && 앞의 항이 false 여도 뒤의 항을 실행 함 => &