Algorithm/백준
-
[Python] 백준 11650 - 좌표 정렬하기Algorithm/백준 2021. 10. 12. 20:45
1. 문제 📚 https://www.acmicpc.net/problem/11650 11650번: 좌표 정렬하기 첫째 줄에 점의 개수 N (1 ≤ N ≤ 100,000)이 주어진다. 둘째 줄부터 N개의 줄에는 i번점의 위치 xi와 yi가 주어진다. (-100,000 ≤ xi, yi ≤ 100,000) 좌표는 항상 정수이고, 위치가 같은 두 점은 없다. www.acmicpc.net 2. 입출력 예 📋 3. 알고리즘 ✅ sorted 함수를 이용하여 정렬한다. ❗️ list를 sort 할 경우는 맨 앞을 기준으로 정렬한다. 4. 소스코드 💻 import sys input = sys.stdin.readline N = int(input()) nums = [] for i in range(N): [a, b] = map..
-
[Python] 백준 2193번 이친수Algorithm/백준 2021. 5. 17. 23:59
1. 문제 📚 2. 입출력 예 📋 3. 알고리즘 ✅ Dp 문제이므로 규칙 또는 점화식을 찾는다 N / 끝의 수 0 1 출력 값(갯수) 1 0 1 1 2 1 0 1 3 1 1 2 4 2 1 3 5 3 2 5 6 5 3 8 규칙을 보면, N이 1과, 2일 땐 1이며 그 이외엔 그 전에 값 2개를 합친 값과 출력 값이 같다는 규칙을 찾을 수 있다. 4. 소스코드 💻 n = int(input()) nums = [1] * n if n == 1 or n == 2: print(1) else: for i in range(2, n): nums[i] = nums[i-1] + nums[i-2] print(nums[n-1])
-
[Python] 백준 2438번 별찍기Algorithm/백준 2021. 5. 8. 22:00
1. 문제 📚 / 입출력 예 📋 3. 알고리즘 ✅ i 번을 받고 i번을 반복하여 별을 찍는다 4. 소스코드 💻 [내가 쓴 코드] n = int(input()) for i in range(1, n+1): while i != 0: print('*', end = '') i -= 1 print() [파이썬 다운 코드] n = int(input()) for i in range(1, n+1): print('*' * i) 파이썬은 string도 곱하기가 된다는 것을 기억하자❗️❗️
-
[Java] 백준 1110번 더하기 사이클Algorithm/백준 2020. 2. 19. 17:45
문제 접근방법 1. 새로운 수의 십의 자릿수 = input의 일의 자릿수 2. 새로운 수의 일의 자릿수 = ( input의 십의 자릿수 + input의 일의 자릿수 ) 의 일의 자릿수 3. 새로운 수 = input 멈추기 해결 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 import java.io.*; public class Main { public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int input = Integer.parseInt(br.readLine()..