알고리즘/Baekjoon
-
[백준][python] 1110번: 더하기 사이클알고리즘/Baekjoon 2022. 1. 31. 16:55
https://www.acmicpc.net/problem/1110 1110번: 더하기 사이클 0보다 크거나 같고, 99보다 작거나 같은 정수가 주어질 때 다음과 같은 연산을 할 수 있다. 먼저 주어진 수가 10보다 작다면 앞에 0을 붙여 두 자리 수로 만들고, 각 자리의 숫자를 더한다. 그 다음, www.acmicpc.net 문제점 십의 자리랑 일의 자리를 문자열화 해서 잇고 숫자로 다시 바꾸는 과정으로 문제를 해결하려고 했음,,,, 1차원적인 생각 ㅜ result = str(second)+str(result%10) result = int(result) 해결 십의 자리는 곱하기 10을 하면 굳이 문자열로 잇지 않아도 잘 이어짐... 그리고 맨 처음 입력했던 수랑 비교하기 위해선 input으로 받은 n을 ..
-
[백준][python] 11021번: A+B - 7알고리즘/Baekjoon 2022. 1. 31. 14:42
https://www.acmicpc.net/problem/11021 11021번: A+B - 7 각 테스트 케이스마다 "Case #x: "를 출력한 다음, A+B를 출력한다. 테스트 케이스 번호는 1부터 시작한다. www.acmicpc.net 내가 푼 방식 - 형식 지정자 말고 그냥 연결해 줬음 t = int(input()) for i in range(1,t+1): a, b = map(int, input().split()) print("Case #",i,":",end=" ") print(a+b) 해결 - 형식 지정자를 사용하자 cases = int(input()) for i in range(cases): a,b = map(int, input().split()) ans = a + b print("Case ..