๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ
Algorithm

[๋ฐฑ์ค€] 15953๋ฒˆ: ์ƒ๊ธˆ ํ—Œํ„ฐ

by ์ฃผ๋ฐœ2 2020. 1. 17.
๋ฐ˜์‘ํ˜•

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

 

15953๋ฒˆ: ์ƒ๊ธˆ ํ—Œํ„ฐ

์ฒซ ๋ฒˆ์งธ ์ค„์— ์ œ์ด์ง€๊ฐ€ ์ƒ์ƒ๋ ฅ์„ ๋ฐœํœ˜ํ•˜์—ฌ ๊ฐ€์ •ํ•œ ํšŸ์ˆ˜ T(1 ≤ T ≤ 1,000)๊ฐ€ ์ฃผ์–ด์ง„๋‹ค. ๋‹ค์Œ T๊ฐœ ์ค„์—๋Š” ํ•œ ์ค„์— ํ•˜๋‚˜์”ฉ ์ œ์ด์ง€๊ฐ€ ํ•ด๋ณธ ๊ฐ€์ •์— ๋Œ€ํ•œ ์ •๋ณด๊ฐ€ ์ฃผ์–ด์ง„๋‹ค. ๊ฐ ์ค„์—๋Š” ๋‘ ๊ฐœ์˜ ์Œ์ด ์•„๋‹Œ ์ •์ˆ˜ a(0 ≤ a ≤ 100)์™€ b(0 ≤ b ≤ 64)๊ฐ€ ๊ณต๋ฐฑ ํ•˜๋‚˜๋ฅผ ์‚ฌ์ด๋กœ ๋‘๊ณ  ์ฃผ์–ด์ง„๋‹ค.

www.acmicpc.net

 

 

 

์ฝ”๋“œ

import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int T = scan.nextInt();
		int[] first  = new int[] {500, 300, 200, 50, 30, 10};
		int[] second = new int[] {512, 256, 128, 64, 32};
		for(int i=0; i<T; i++) {
			int money = 0;
			int a = scan.nextInt();
			int b = scan.nextInt();
			if(a == 1)
				money += first[0];
			else if(a > 1 && a <= 3)
				money += first[1];
			else if(a > 3 && a <= 6 )
				money += first[2];
			else if(a > 6 && a <= 10)
				money += first[3];
			else if(a > 10 && a <= 15)
				money += first[4];
			else if(a > 15 && a <= 21)
				money += first[5];
			else
				money = 0;
			
			if(b == 1)
				money += second[0];
			else if(b > 1 && b <= 3)
				money += second[1];
			else if(b > 3 && b <= 7)
				money += second[2];
			else if(b > 7 && b <= 15)
				money += second[3];
			else if(b > 15 && b <= 31)
				money += second[4];
			
			System.out.println(money * 10000);
		}
		scan.close();
	}

}

 

 

import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int T = scan.nextInt();
		int[] first  = new int[] {500, 300, 300, 200, 200, 200, 50, 50, 50, 50, 30, 30, 30, 30, 30, 10, 10, 10, 10, 10, 10};
		int[] second = new int[] {512, 256, 256, 128, 128, 128, 128, 64, 64, 64, 64, 64, 64, 64, 64, 
				32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32};
		for(int i=0; i<T; i++) {
			int money = 0;
			int a = scan.nextInt();
			int b = scan.nextInt();
			if(a > 0 && a <= 21)
				money += first[a-1];
			if(b > 0 && b <= 31)
				money += second[b-1];
			
			System.out.println(money * 10000);
		}
		
		scan.close();
	}
}
๋ฐ˜์‘ํ˜•

๋Œ“๊ธ€