๐Ÿ•ธ Algorithm/๐Ÿ•ธ ๋ฐฑ์ค€ BaekJoon

[๋ฐฑ์ค€][java][2480][์ฃผ์‚ฌ์œ„ ์„ธ๊ฐœ]

๋‰ด์ด NUEY 2023. 9. 30. 17:37
๋ฐ˜์‘ํ˜•

import java.util.Scanner;

// 2480	์ฃผ์‚ฌ์œ„ ์„ธ๊ฐœ
public class Main {

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

		int reward = 0;
		int max = 0;
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		
		sc.close();

		if (a == b) {
			if (b == c) reward = 1;
			else reward = 2;
			
			max = a;
		}
		else if (a == c) {
			if (c == b) reward = 1;
			else reward = 2;
			
			max = a;
		}
		else if (b == c) {
			if (c == a) reward = 1;
			else reward = 2;
			
			max = b;
		}
		else {
			reward = 3;
			
			max = Math.max(a, Math.max(b, c));
		} 
		
		switch (reward) {
		case 1: reward = 10000 + max*1000; 
			break;
		case 2: reward = 1000 + max*100;
			break;
		case 3: reward = max * 100;
			break;
		default:break;
		}
		
		System.out.print(reward);
	}
}
  • ์ฃผ์‚ฌ์œ„๋ฅผ ๋˜์กŒ์„ ๋•Œ ๋‘๊ฐœ๊ฐ€ ๊ฐ™์€ ๊ฐ’์ด ๋‚˜์˜ค๋Š” 3๊ฐ€์ง€์˜ ๊ฒฝ์šฐ๋ฅผ if๋ฌธ์œผ๋กœ ๋‚˜๋ˆ„์—ˆ์Šต๋‹ˆ๋‹ค.
  • ํ•˜๋‚˜๋„ ์ผ์น˜ํ•˜์ง€ ์•Š๋Š” ๊ฒฝ์šฐ๋Š” else()์—์„œ Math.max()ํ•จ์ˆ˜๋ฅผ ์ด์šฉํ•ด์„œ ๊ฐ€์žฅ ํฐ ๊ฐ’์„ ๊ตฌํ•ฉ๋‹ˆ๋‹ค.
  • ํ•ด๋‹นํ•˜๋Š” ์ƒ๊ธˆreward์— ๋”ฐ๋ผ ์ถœ๋ ฅ๋ฉ๋‹ˆ๋‹ค.

 

 

๋ฐ˜์‘ํ˜•