문제 : 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+ " ");
		}
	} 
 }

문제 : 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]);
	 }
   }
 }

https://www.acmicpc.net/problem/2577

import java.util.Scanner;

public class Main {
 public static void main (String [] args ) {
	 int a = 0;
	 int b = 0;
	 int c = 0;
	 int mul = 0;
	 
	 Scanner scan = new Scanner (System.in);
	 a = scan.nextInt();
	 b = scan.nextInt();
	 c = scan.nextInt();
	 
	 mul = a*b*c ;
	 String parseMul = Integer.toString(mul);
	 
	 
	 int [][] arr = new int [10][2];
	 
	 
	 for(int j = 0 ; j <10 ; j++) {
		 for (int i = 0; i <parseMul.length(); i ++ ) {
//			 System.out.println("parseMul : "+Character.getNumericValue((parseMul.charAt(i))));
//			 System.out.println("check num : "+Integer.toString(j));
//			 System.out.println("is Equal : "+ (Character.getNumericValue(parseMul.charAt(i)) == j));
//			 
			 if(Character.getNumericValue((parseMul.charAt(i))) == j){
				 arr[j][1]++;
			 }
		 }
		 System.out.println(arr[j][1]);
	 }
	 	 
 }
	
}

https://www.acmicpc.net/problem/1152

import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		String input = "";
		int count =0;
		Scanner scan = new Scanner(System.in);
		boolean check = false;
		input = scan.nextLine();
		input = input.trim();
		
		String []a = input.split(" ");
		//System.out.println("배열 개수"+a.length);
		for(int i = 0; i <a.length; i++) {
			

//			System.out.println("값은 '"+a[i]+"'입니다"); 
			// 띄어쓰기만 입력하거나 아무것도 입력하지 않았을때 split 함수는 내용이 없는 배열(배열의 값 "") 1개를 만들어냄 
			// a[0].equals("") 이면 첫번째 값이 없는 것이므로 count 를하지 않음
			
//			System.out.println(a[i].length());
			//띄어쓰기가 두번 연속으로 들어간 경우  배열 안에 ""가 들어감.  
			//두가지 경우를 모두 만족하는 조건은 a[i].length()가 0이 아닌경우
			
			if(a[i].length()!=0) {
				count++;
			}
		}
		System.out.println(count);
	}
}

+ Recent posts

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