문제 : https://www.acmicpc.net/problem/2941


import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		String input = scan.nextLine();
		String [] replaceStr = {"c=", "c-", "dz=", "d-", "lj", "nj","s=","z="};

		for(String str : replaceStr) {			
			input = input.replace(str,"a");
		}
		System.out.println(input.length());
		scan.close();
	}
}

문제 : https://www.acmicpc.net/problem/5622


import java.util.Scanner;
import java.util.StringTokenizer;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);

		int time = 0 ;
		String input = scan.nextLine();		

		for(int i = 0 ; i < input.length(); i ++) {
			char charIndex = input.charAt(i);
			if( charIndex >='A' && charIndex <= 'C' ) {
				time += 3;
			} else if( charIndex >='D' && charIndex <= 'F' ) {
				time += 4;
			} else if( charIndex >='G' && charIndex <= 'I' ) {
				time += 5;
			} else if( charIndex >='J' && charIndex <= 'L' ) {
				time += 6;
			} else if( charIndex >='M' && charIndex <= 'O' ) {
				time += 7;
			} else if( charIndex >='P' && charIndex <= 'S' ) {
				time += 8;
			} else if( charIndex >='T' && charIndex <= 'V' ) {
				time += 9;
			} else if( charIndex >='W' && charIndex <= 'Z' ) {
				time += 10;
			}
		}
		System.out.println(time);
	}
}

문제 : https://www.acmicpc.net/problem/2908


import java.util.Scanner;
import java.util.StringTokenizer;
public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		String input = scan.nextLine();
		String str = "";
		for (int i = input.length() - 1; i >= 0; i--) {
			str += input.charAt(i);
		}

		StringTokenizer strTokenizer = new StringTokenizer(str, " ");
		int numA = 0;
		int numB = 0;

		if (strTokenizer.hasMoreTokens()) {
			numA = Integer.parseInt(strTokenizer.nextToken());
		}
		if (strTokenizer.hasMoreTokens()) {
			numB = Integer.parseInt(strTokenizer.nextToken());
		}

		if (numA - numB > 0) {
			System.out.println(numA);
		} else {
			System.out.println(numB);
		}
		scan.close();
	}
}


문제 : https://www.acmicpc.net/problem/10809 



import java.util.Scanner;
 public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		String input = scan.nextLine();
	
		String [] chk = new String [26];
		
		for(int i = 0 ; i < input.length() ; i ++) {
			int index =input.charAt(i)-'a';
			if(chk[index]==null) {				
				chk[index] = Integer.toString(i);
			}
		}
		for(String idx : chk) {
			String result = idx==null ? "-1" :idx ;
			System.out.print(result+ " ");
		}
	} 
 }

- jsp 경로 받기


${pageContext.request.requestURI}



- forward 되는 주소값 그대로 받기


${requestScope['javax.servlet.forward.request_uri']}






문제 : https://www.acmicpc.net/problem/10039



import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int s = 0; 
		int sum = 0; 
		for(int i = 0; i < 5 ; i++) {
			s= scan.nextInt();
			if(s>100 || s <0 || s%5 != 0 ) {
				s = 0;
			} else if(s < 40) {
				s = 40;
			}
			sum = s +sum;
		}
		System.out.println(sum/5);
		}
}
 

문제 : https://www.acmicpc.net/problem/8958



import java.util.Scanner;
public class Main {
 public static void main (String [] args ) {
	 int num = 0;
	 int total[][];	 

	 Scanner scan = new Scanner (System.in);
	 num = scan.nextInt();
	 scan = scan.skip("[\\n\\r]+");
	 total = new int[num][2];
	 String answer ="" ;
	 int weight = 0;
	 
	 for(int i = 0; i <num ; i ++) {
		  answer = scan.nextLine();
		 answer = answer.replaceAll("O", "1");
		 answer = answer.replaceAll("X", "0");		 

		 for(int j = 0 ; j < answer.length(); j++) { 
			 if(Character.getNumericValue(answer.charAt(j)) == 1) {
				 total[i][1]++;
				 if( j != 0 && Character.getNumericValue( answer.charAt(j-1)) == 1 ) {
					 weight = weight+Character.getNumericValue( answer.charAt(j));
				 } else {
					 weight = 0;
				 }		
				 total[i][1] = weight +total[i][1];
			 }
		 }
	 } 
	 for(int i = 0 ; i < total.length; i++) {
		 System.out.println(total[i][1]);
	 }
   }
 }

+ Recent posts

"여기"를 클릭하면 광고 제거.