본문 바로가기

코딩테스트(백준)

(46)
[백준] 4948 : 베르트랑 공준 -JAVA - 사좋배 공유 import java.util.Scanner; public class Main { public static void main(String[] args) { int[] arr =new int[200000]; int i=0; int cnt=0; int count=0; Scanner sc = new Scanner(System.in); int number=1; while(number!=0) { number=sc.nextInt(); arr[i]=number; i++; } for(int j=0;j
[백준] 2960 : 에라토스테네스의 체 -JAVA - 사좋배 공유 import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc1= new Scanner(System.in); int N=sc1.nextInt(); int K=sc1.nextInt(); int [] arr = new int [N-1]; int [] temparr = new int[N-1]; int temp; int cnt=0; for(int i=0;i
[백준] 2941 : 크로아티아 알파벳 -JAVA - 사좋배 공유 import java.util.Scanner; public class Main { public static void main(String[] args) { // TODO Auto-generated method stub Scanner sc =new Scanner(System.in); String s = sc.next(); int cnt=0; char temp=' '; //String arr[] = {"c=","c-","dz=","d-","lj","nj","s=","z="}; for(int i=s.length()-1;i>=0;i--) { if(s.charAt(i)=='=') { if(i-1>=0&&(s.charAt(i-1)=='c'||s.charAt(i-1)=='s')) { i--; cnt++; }else ..
[백준] 2667 : 단지번호붙이기 -JAVA - 사좋배 공유 import java.util.ArrayList; import java.util.Arrays; import java.util.Scanner; public class Main { static int arr[][]; static int dx[]= {-1,0,1,0}; static int dy[]= {0,1,0,-1}; static boolean visit[][]; static int color; static int size; public static void main(String[] args) { Scanner sc = new Scanner(System.in); size = Integer.parseInt(sc.nextLine()); arr= new int[size][size]; visit=new boolea..
[백준] 2146- 다리 만들기 - JAVA - 사좋배 공유 import java.util.LinkedList; import java.util.Queue; import java.util.Scanner; public class Main { //visit에다가count 숫자를 넣고 //arr[][]에는 영역을 넓혀나간다 static int dx [] = {-1,0,1,0}; static int dy [] = {0,1,0,-1}; static int visit[][]; static int arr[][]; static Queue q; static int result; static int N; static int min; static void BFS() { while(!q.isEmpty()) { island temp= q.poll(); int x = temp.x; int ..
[백준] 1697 - 숨바꼭질 - JAVA - 사좋배 공유 import java.util.Scanner; import java.util.LinkedList; import java.util.Queue; import java.util.Scanner; public class Main { static int result; static Queue q; static int [] arr; static int N; static int K; static int min=Integer.MAX_VALUE; public static void main(String[] args) { Scanner sc= new Scanner(System.in); N =sc.nextInt(); K = sc.nextInt(); arr=new int[100005]; q= new LinkedList(); q.a..
[백준] 2563번: 색종이 -JAVA - 사좋배 공유 답 : import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int array[][]= new int[100][100]; int cnt=0; int number =sc.nextInt(); for(int i=0;i
[백준] 5063번: TGN -JAVA - 사좋배 공유 문제 : 답 : import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int number = sc.nextInt(); int array[][]= new int[3][number]; int notad; int ad; int pay; for(int i=0;ie-c) { System.out.println("do not advertise"); } else if(r==e-c) { System.out.println("does not matter"); } else { System.out.println("advertise"); } } } }