본문 바로가기

전체 글

(278)
[Baekjoon] 2439번 / 별 찍기 - 2 문제 첫째 줄에는 별 1개, 둘째 줄에는 별 2개, N번째 줄에는 별 N개를 찍는 문제 하지만, 오른쪽을 기준으로 정렬한 별(예제 참고)을 출력하시오. 입력 첫째 줄에 N(1
[Baekjoon] 10172번 / 개 문제 아래 예제와 같이 개를 출력하시오. 입력 없음. 출력 개를 출력한다. 예제 출력 |\_/| |q p| /} ( 0 )"""\ |"^"` | ||_/=\\__| import java.util.*; public class Main { public static void main(String[] args) { System.out.println("|\\_/|"); System.out.println("|q p| /}"); System.out.println("( 0 )\"\"\"\\"); System.out.println("|\"^\"` |"); System.out.println("||_/=\\\\__|"); } } - 쌍따옴표(")를 출력하고싶을땐 역슬레시(\)를 앞에 추가해준다. - 역슬레시를 출력하고싶을때..
[Baekjoon] 2741번 / N 찍기 문제 자연수 N이 주어졌을 때, 1부터 N까지 한 줄에 하나씩 출력하는 프로그램을 작성하시오. 입력 첫째 줄에 100,000보다 작거나 같은 자연수 N이 주어진다. 출력 첫째 줄부터 N번째 줄 까지 차례대로 출력한다. 예제 입력 5 예제 출력 1 2 3 4 5 import java.util.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int N = sc.nextInt(); for(int i=1; i
[Baekjoon] 10430번 / 나머지 문제 (A+B)%C는 ((A%C) + (B%C))%C 와 같을까? (A×B)%C는 ((A%C) × (B%C))%C 와 같을까? 세 수 A, B, C가 주어졌을 때, 위의 네 가지 값을 구하는 프로그램을 작성하시오. 입력 첫째 줄에 A, B, C가 순서대로 주어진다. (2 ≤ A, B, C ≤ 10000) 출력 첫째 줄에 (A+B)%C, 둘째 줄에 ((A%C) + (B%C))%C, 셋째 줄에 (A×B)%C, 넷째 줄에 ((A%C) × (B%C))%C를 출력한다. 예제 입력1 5 8 4 예제 출력1 1 1 0 0 import java.util.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(Syst..
[Hackerrank] Operators Objective In this challenge, you will work with arithmetic operators. Check out the Turtorial tab for learning materials and an instructional video. Task Given the meal price (base cost of a meal), tip percent (the percentage of the meal price being added as tip), and tax percent (the percentage of the meal price being added as tax) for a meal, find and print the meal's total cost. Round the res..
[Hackerrank] Data Types Objective Today, we're discussing data types. check out the Tutorial tab for learning materials and an instructional video! Task Complete the code in the editor below. The variables i, d, and s are already declared and initalized for you. You must: 1. Declare 3 variables: one of type int, one of type double, and one of type String. 2. Read 3 lines of input from stdin (according to the sequence g..
[Hackerrank] Picking Numbers Given an array of integers, find the longest subarray where the absolute difference between any two elements is less than or equal to 1. Example a = [1,1,2,2,4,4,5,5,5] There are two subarrays meeting the criterion: [1,1,2,2] and [4,4,5,5,5]. The maximum length subarray has 5 elements. Function Description Complete the pickingNumbers function in the editor below. pickingNumbers has the following..
[Hackerrank] Forming a Magic Square We define a magic square to be an n x n matrix of distinct positive integers from 1 to n2 where the sum of any row, column, or diagonal of length n is always equal to the same number: the magic constant. You will be gicen a 3 x 3 matrix s of integers in the inclusive range [1,9]. We can convert any digit a to any other digit b in the range [1,9] at cost of |a-b|. Given s, convert it into a magic..