본문 바로가기

알고리즘/백준39

[Python] 백준 8393번 - 합 https://www.acmicpc.net/problem/8393 8393번: 합 문제 n이 주어졌을 때, 1부터 n까지 합을 구하는 프로그램을 작성하시오. 입력 첫째 줄에 n (1 ≤ n ≤ 10,000)이 주어진다. 출력 1부터 n까지 합을 출력한다. 예제 입력 1 복사 3 예제 출력 1 복사 6... www.acmicpc.net n = int(input()) numbers = [] while n: for i in range(1, n+1): numbers.append(i) n -= 1 print(sum(numbers)) 2020. 6. 9.
[Python/Java] 백준 10950번 - A+B - 3 https://www.acmicpc.net/problem/10950 10950번: A+B - 3 두 정수 A와 B를 입력받은 다음, A+B를 출력하는 프로그램을 작성하시오. www.acmicpc.net Python times = int(input()) result = [] while times: times -= 1 a, b = map(int, input().split()) result.append(a+b) for i in result: print(i) Java import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner scan = new Scanner(System.in); int n = scan.. 2020. 6. 9.
[Python/Java] 백준 2739번 - 구구단 https://www.acmicpc.net/problem/2739 2739번: 구구단 N을 입력받은 뒤, 구구단 N단을 출력하는 프로그램을 작성하시오. 출력 형식에 맞춰서 출력하면 된다. www.acmicpc.net Python n = int(input()) for i in range(1, 10): multi = n * i print("%d * %d = %d" % (n, i, multi)) Java import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner scan = new Scanner(System.in); int n = scan.nextInt(); for(int i = 1; i 2020. 6. 9.
[Python/Java] 백준 2884번 - 알람 시계 https://www.acmicpc.net/problem/2884 2884번: 알람 시계 문제 상근이는 매일 아침 알람을 듣고 일어난다. 알람을 듣고 바로 일어나면 다행이겠지만, 항상 조금만 더 자려는 마음 때문에 매일 학교를 지각하고 있다. 상근이는 모든 방법을 동원해보았지 www.acmicpc.net Python H, M = map(int, input().split()) if M = 45 : print(H, M-4.. 2020. 6. 8.
[Python/Java] 백준 14681번 - 사분면 고르기 https://www.acmicpc.net/problem/14681 14681번: 사분면 고르기 문제 흔한 수학 문제 중 하나는 주어진 점이 어느 사분면에 속하는지 알아내는 것이다. 사분면은 아래 그림처럼 1부터 4까지 번호를 갖는다. "Quadrant n"은 "제n사분면"이라는 뜻이다. 예를 들어, 좌 www.acmicpc.net Python x = int(input()) y = int(input()) if (x > 0) and (y > 0) : print(1) elif (x 0): print(2) elif (x > 0) and (y < 0): print(4) else: pass Java import java.ut.. 2020. 6. 8.