1234567891011121314151617181920212223import java.io.BufferedReader;import java.io.BufferedWriter;import java.io.IOException;import java.io.InputStreamReader;import java.io.OutputStreamWriter; class Solution { private static BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); private static BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out)); public st..
알고리즘 풀이
StringBuilder 인스턴스를 그대로 넣어준 것과 StringBuilder의 toString()함수를 붙여준 것과의 차이점은 무엇인가요? There's nothing different between line 6 and line 8. PrintStream.println(Object) calls string.valueOf(Object) which calls the object's toString() method, and that gets printed. System.out.println(s) and System.out.println(s.toString()) have the same output (unless s is null, in which case the latter throws an excepti..
StringBuilder replace로 하려고 했는데 함수가 없음 String.replace로 해결 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.IOException; import java.io.InputStreamReader; import java.io.OutputStreamWriter; class Solution { private static BufferedReader br = new BufferedReader(new InputStreamReader(Syste..
split함수를 공백을 기준으로 쪼갰을 때 공백이 2연속되는 경우에는 공백 사이의 null값을 배열의 요소로 정의한다는 것을 알게 되었다 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.IOException; import java.io.InputStreamReader; import java.io.OutputStreamWriter; class Solution { private static BufferedReader br = new BufferedReader(n..
1234567891011121314import java.util.Scanner; public class HelloWorld { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int p = sc.nextInt(); int k = sc.nextInt(); System.out.println(p-k+1); }}Colored by Color Scriptercs
12345678910111213141516171819import java.io.BufferedReader;import java.io.BufferedWriter;import java.io.IOException;import java.io.InputStreamReader;import java.io.OutputStreamWriter; class Solution { private static BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); private static BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out)); public static voi..
함수~컷 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.IOException; import java.io.InputStreamReader; import java.io.OutputStreamWriter; class Solution { private static BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); private static BufferedWriter bw = new BufferedWriter(new OutputStreamWrit..
알파벳 char들을 숫자로 변환 (Character.getNumericValue(??))후에 받아온 A의 아스키코드 값을 1로 맞춰줌 ( 변환 후에 9를 빼주면 됨 ) = 받아온 B의 아스키코드 값을 2로 맞춰줌 ( 변환 후에 9를 빼주면 됨 ) = ... 그냥 9빼주면 됨 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.IOException; import java.io.InputStreamReader; import java.io.OutputStreamWriter; class Solution {..
10^9 큰 숫자 대비용 long으로 선언 가로m과 세로n을 각각 a로 나눈 값 x,y를 곱해준다 나눴을 때 나머지가 0이 아닌 경우에는 +1을 해준다 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 import java.util.Scanner; public class HelloWorld { public static void main(String[] args) { Scanner sc = new Scanner(System.in); long m = sc.nextInt(); long n = sc.nextInt(); long a = sc.nextInt(); long x = m/a; long y = n/a; if(m%a!=0) x++; if(n%a!=0) y+..
2명이상 풀 수 있는 문제 counting해줌 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.IOException; import java.io.InputStreamReader; import java.io.OutputStreamWriter; public class HelloWorld { private static BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); private sta..