TitanYang's Programming
이 문제는 피보나치 수입니다. 기본적인 피보나치 수열에 관한 문제인데요, 다만 재귀함수형식으로 풀었을때 시간 초과가 나게 되어있는듯합니다. 따라서 재귀 이외에 다른 방법으로 풀어야겠습니다. 123456789101112131415161718192021222324252627282930import java.util.Scanner; public class ekdmaanswp { public static void main(String[] args) { // TODO Auto-generated method stub Scanner sc= new Scanner(System.in); int n=sc.nextInt(); int a=0,b=1; if(n==0) { System.out.println(a); return; }i..
이번 문제는 지능형 기차라는 문제입니다. 이 문제는 최대 값을 구하는 가장 기초적인 문제였습니다. 123456789101112131415161718192021import java.util.Scanner; public class dur { public static void main(String[] args) { // TODO Auto-generated method stub Scanner sc= new Scanner(System.in); int max=0,in=0,out=0,now=0; for(int i=0;inow?max:now; } System.out.println(max); } } Colored by Color Scriptercs 역이 4개라고 정해져있으므로, for문을 4번돌릭게 설정하였구요, 만약 ..
이번 문제는 뽑기와 비슷했습니다. 일정한 규칙에 의해 뽑힐때 총량이 줄어들었어요. 그래서 처음에 하나하나 제외시키는 알고리즘으로 짜보았습니다. 12345678910111213141516171819202122232425262728293031323334import java.util.*;public class whtpvjtm { static Scanner sc = new Scanner(System.in); static int n=sc.nextInt(); static int m=sc.nextInt(); static int io[]= new int[n]; static int x=0;static int a=0; public static void out(){ int cnt=0; for(int i=x;;i++) { i..