Deep_Dev
article thumbnail
[๋ฐฑ์ค€][JAVA]2101๋ฒˆ : ํ†ต๊ณ„ํ•™

์ตœ๋นˆ๊ฐ’๋งŒ ์œ ์˜ํ•ด์„œ ๊ตฌํ•˜๋ฉด ๋œ๋‹ค. ์ตœ๋นˆ๊ฐ’์ด 2๊ฐœ ์ด์ƒ์ผ๋•Œ๋Š” 2๋ฒˆ์งธ๋กœ ์ž‘์€๊ฐ’์„ ์ถœ๋ ฅํ•˜๋Š”๊ฒƒ์ด๊ณ , ์Œ์ˆ˜๊ฐ€ ๋“ค์–ด์˜ฌ ์ˆ˜๋„ ์žˆ๊ธฐ์— 1์ฐจ์› ๋ฐฐ์—ด์„ ์ƒ์„ฑํ•ด์„œ ๋นˆ๋„์ˆ˜๋ฅผ ๊ตฌํ•˜๋Š” ๋ฐฉ์‹์€ ์•ˆ๋œ๋‹ค. import java.util.*; class Main { public static void main(String args[]) throws Exception { Scanner kb = new Scanner(System.in); int n=kb.nextInt(); int[] arr=new int[n]; int[][] cnt=new int[4001][2]; // ์ตœ๋นˆ๊ฐ’ ๊ตฌํ•  2์ฐจ์›๋ฐฐ์—ด ( ์–‘์ˆ˜:0์—ด ์Œ์ˆ˜:1์—ด ) int sum=0; int max=Integer.MIN_VALUE; // ์ตœ๋Œ€๊ฐ’ ์ฐพ๊ธฐ ์œ„ํ•œ ๋ณ€์ˆ˜ for(int i=0; i0..

article thumbnail
[ํ”„๋กœ๊ทธ๋ž˜๋จธ์Šค][JAVA]Level 0 : ํŠน์ดํ•œ ์ •๋ ฌ

import java.util.*; class Solution { public int[] solution(int[] numlist, int n) { int[] answer=new int[numlist.length]; ArrayList list=new ArrayList(); for(int i=0; ib){ return -1; }else{ return 1; } }else{ return absA-absB; } } }); for(int i=0; i

article thumbnail
[ํ”„๋กœ๊ทธ๋ž˜๋จธ์Šค][JAVA]Level 0 : ์น˜ํ‚จ์ฟ ํฐ

๊ทธ๋ƒฅ ๊ตฌํ˜„๋ฌธ์ œ.. import java.util.*; class Main { public int solution(int chicken) { int answer = 0; int temp = 0; while (chicken >= 10) { answer += chicken / 10; temp = chicken % 10; chicken = chicken / 10 + temp; } return answer; } }

[๋ฐฑ์ค€][JAVA]15829๋ฒˆ : Hashing

Hashing ๋ถ€๋ถ„ ์„ฑ๊ณต์„œ๋ธŒํƒœ์Šคํฌ ์‹œ๊ฐ„ ์ œํ•œ๋ฉ”๋ชจ๋ฆฌ ์ œํ•œ์ œ์ถœ์ •๋‹ต๋งžํžŒ ์‚ฌ๋žŒ์ •๋‹ต ๋น„์œจ 1 ์ดˆ 512 MB 32492 10101 8685 30.995% ๋ฌธ์ œ APC์— ์˜จ ๊ฒƒ์„ ํ™˜์˜ํ•œ๋‹ค. ๋งŒ์•ฝ ์—ฌ๋Ÿฌ๋ถ„์ด ํ•™๊ต์—์„œ ์ž๋ฃŒ๊ตฌ์กฐ๋ฅผ ์ˆ˜๊ฐ•ํ–ˆ๋‹ค๋ฉด ํ•ด์‹œ ํ•จ์ˆ˜์— ๋Œ€ํ•ด ๋ฐฐ์› ์„ ๊ฒƒ์ด๋‹ค. ํ•ด์‹œ ํ•จ์ˆ˜๋ž€ ์ž„์˜์˜ ๊ธธ์ด์˜ ์ž…๋ ฅ์„ ๋ฐ›์•„์„œ ๊ณ ์ •๋œ ๊ธธ์ด์˜ ์ถœ๋ ฅ์„ ๋‚ด๋ณด๋‚ด๋Š” ํ•จ์ˆ˜๋กœ ์ •์˜ํ•œ๋‹ค. ํ•ด์‹œ ํ•จ์ˆ˜๋Š” ๋ฌด๊ถ๋ฌด์ง„ํ•œ ์‘์šฉ ๋ถ„์•ผ๋ฅผ ๊ฐ–๋Š”๋ฐ, ๋Œ€ํ‘œ์ ์œผ๋กœ ์ž๋ฃŒ์˜ ์ €์žฅ๊ณผ ํƒ์ƒ‰์— ์“ฐ์ธ๋‹ค. ์ด ๋ฌธ์ œ์—์„œ๋Š” ์—ฌ๋Ÿฌ๋ถ„์ด ์•ž์œผ๋กœ ์œ ์šฉํ•˜๊ฒŒ ์“ธ ์ˆ˜ ์žˆ๋Š” ํ•ด์‹œ ํ•จ์ˆ˜๋ฅผ ํ•˜๋‚˜ ๊ฐ€๋ฅด์ณ์ฃผ๊ณ ์ž ํ•œ๋‹ค. ๋จผ์ €, ํŽธ์˜์ƒ ์ž…๋ ฅ์œผ๋กœ ๋“ค์–ด์˜ค๋Š” ๋ฌธ์ž์—ด์—๋Š” ์˜๋ฌธ ์†Œ๋ฌธ์ž(a, b, ..., z)๋กœ๋งŒ ๊ตฌ์„ฑ๋˜์–ด์žˆ๋‹ค๊ณ  ๊ฐ€์ •ํ•˜์ž. ์˜์–ด์—๋Š” ์ด 26๊ฐœ์˜ ์•ŒํŒŒ๋ฒณ์ด ์กด์žฌํ•˜๋ฏ€๋กœ a์—๋Š” 1, b์—๋Š” 2, c์—๋Š” 3, ...

article thumbnail
[๋ฐฑ์ค€][JAVA]2609๋ฒˆ : ์ตœ๋Œ€๊ณต์•ฝ์ˆ˜์™€ ์ตœ์†Œ๊ณต๋ฐฐ์ˆ˜

์ตœ๋Œ€๊ณต์•ฝ์ˆ˜์™€ ์ตœ์†Œ๊ณต๋ฐฐ์ˆ˜ ---> ์œ ํด๋ฆฌ๋“œ ํ˜ธ์ œ๋ฒ• ๐Ÿ’ก ์ตœ๋Œ€๊ณต์•ฝ์ˆ˜ int gcd(int a, int b){ if(b==0) return a; return gcd(b,a%b); } ๐Ÿ’ก ์ตœ์†Œ๊ณต๋ฐฐ์ˆ˜ a*b / ์ตœ๋Œ€๊ณต์•ฝ์ˆ˜ import java.util.*; class Main { public static void main(String args[]) throws Exception { Scanner kb = new Scanner(System.in); int a = kb.nextInt(); int b = kb.nextInt(); int max=gcd(a,b); // ์ตœ๋Œ€๊ณต์•ฝ์ˆ˜ int min=(a*b)/max; System.out.println(max); System.out.print(min); } static int g..

article thumbnail
[ํ”„๋กœ๊ทธ๋ž˜๋จธ์Šค][JAVA]Level 0 : ์บ๋ฆญํ„ฐ์˜ ์ขŒํ‘œ

keyinput.length ๋งŒํผ ๋ฐ˜๋ณต๋ฌธ์—์„œ ์กฐ๊ฑด๋ฌธ๋งŒ ์ž˜ ๊ฑธ์–ด์ฃผ๋ฉด ํ•ด๊ฒฐ๋˜๋Š” ๋ฌธ์ œ ์ฃผ์˜ํ• ์ ์€ ์ฃผ์–ด์ง„ board๊ธธ์ด/2 ์— ํ•ด๋‹นํ•˜๋Š” ๊ฐ’๊นŒ์ง€๋งŒ ์›€์ง์ผ ์ˆ˜ ์žˆ๋‹ค๋Š”๊ฒƒ ( ์Œ์ˆ˜ ์ฒ˜๋ฆฌ ์‹ ๊ฒฝ์“ฐ๊ธฐ ) class Solution { public int[] solution(String[] keyinput, int[] board) { int[] answer = {0,0}; for(int i=0; i answer[0] if(keyinput[i].equals("left")||keyinput[i].equals("right")){ if(keyinput[i].equals("left")){ if(answer[0]>-(board[0]/2)) answer[0]--; }else{ if(answer[0] answer[1] }else{ if(k..

article thumbnail
[ํ”„๋กœ๊ทธ๋ž˜๋จธ์Šค][JAVA]Level 0 : ์ด์ง„์ˆ˜ ๋”ํ•˜๊ธฐ

ํ˜•๋ณ€ํ™˜๋งŒ ์ž˜ํ•ด์„œ ํ’€์–ด์ฃผ๋ฉด ๋œ๋‹ค. ์ฒซ๋ฒˆ์งธ ์ฝ”๋“œ import java.math.BigInteger; class Solution { public String solution(String bin1, String bin2) { String answer = ""; BigInteger a=new BigInteger(bin1,2); BigInteger b=new BigInteger(bin2, 2); BigInteger sum=a.add(b); answer=sum.toString(2); return answer; } } ์กฐ๊ธˆ ๋” ์งง๊ฒŒ ๋ฐ”๊พผ ๋‘๋ฒˆ์งธ ์ฝ”๋“œ import java.math.BigInteger; class Solution { public String solution(String bin1, String bin2) ..

article thumbnail
[ํ”„๋กœ๊ทธ๋ž˜๋จธ์Šค][JAVA]Level 0 : ๊ตฌ์Šฌ์„ ๋‚˜๋ˆ„๋Š” ๊ฒฝ์šฐ์˜ ์ˆ˜ ( *DFS, ๋ฉ”๋ชจ์ด์ œ์ด์…˜ )

n๊ฐœ์ค‘์—์„œ r๊ฐœ๋ฅผ ์„ ํƒํ•˜๋Š” ์กฐํ•ฉ ๋ฐฉ๋ฒ•.. nCr => n-1Cr + n-1Cr-1 .. DFS ์ด์šฉํ•ด์„œ ํ’€์ด. class Solution { int[][] dy=new int[31][31]; public int DFS(int n, int r){ if(dy[n][r]>0) return dy[n][r]; if(r==0||n==r){ return 1; }else return DFS(n-1,r-1)+DFS(n-1,r); } public int solution(int balls, int share) { return DFS(balls, share); } }