๊ธฐ๋ก๋ฐฉ

BOJ_2338 : ๊ธด์ž๋ฆฌ ๊ณ„์‚ฐ ๋ณธ๋ฌธ

CodingTest/Java

BOJ_2338 : ๊ธด์ž๋ฆฌ ๊ณ„์‚ฐ

Soom_1n 2022. 10. 4. 15:09

๐Ÿ‘‰ ๋ฌธ์ œ๋งํฌ

 

2338๋ฒˆ: ๊ธด์ž๋ฆฌ ๊ณ„์‚ฐ

์ฒซ์งธ ์ค„์— A+B, ๋‘˜์งธ ์ค„์— A-B, ์…‹์งธ ์ค„์— A×B๋ฅผ ์ถœ๋ ฅํ•œ๋‹ค. ๊ฐ๊ฐ์„ ์ถœ๋ ฅํ•  ๋•Œ, ๋‹ต์ด 0์ธ ๊ฒฝ์šฐ๋ฅผ ์ œ์™ธํ•˜๊ณ ๋Š” 0์œผ๋กœ ์‹œ์ž‘ํ•˜๊ฒŒ ํ•ด์„œ๋Š” ์•ˆ ๋œ๋‹ค(1์„ 01๋กœ ์ถœ๋ ฅํ•˜๋ฉด ์•ˆ ๋œ๋‹ค๋Š” ์˜๋ฏธ).

www.acmicpc.net



๐Ÿ”ธ ๋ฌธ์ œ ๋ถ„์„ ๐Ÿ”ธ

  • ํฐ ์ˆ˜ A, B์˜ ํ•ฉ ์ฐจ ๊ณฑ์„ ์ถœ๋ ฅํ•œ๋‹ค.

๐Ÿ”ธ ์ฝ”๋“œ ๐Ÿ”ธ

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.math.BigInteger;

public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

        BigInteger a = new BigInteger(br.readLine());
        BigInteger b = new BigInteger(br.readLine());

        System.out.println(a.add(b));
        System.out.println(a.subtract(b));
        System.out.println(a.multiply(b));
    }
}

๐Ÿ”ธ ์ฝ”๋“œ ํ•ด์„ ๐Ÿ”ธ

  • A, B์˜ ๋ฒ”์œ„๋Š” 10์ง„์ˆ˜๋กœ 1000์˜ ์ž๋ฆฌ๊นŒ์ง€ ๊ฐ€๋Š” ํฐ ์ˆ˜์ด๋ฏ€๋กœ BigInteger๋ฅผ ์ด์šฉํ•ด ์ž…๋ ฅ๋ฐ›์•„ ๊ณ„์‚ฐํ•œ๋‹ค.

๐Ÿ”ธ end ๐Ÿ”ธ

  • ๊ฐ„๋‹จํ•œ ๋ฌธ์ œ์˜€์ง€๋งŒ ํฐ ์ˆ˜ ์—ฐ์‚ฐ์„ ํ•  ์ค„ ๋ชฐ๋ผ ๋งŽ์ด ํ‹€๋ ธ๋˜ ๋ฌธ์ œ์ด๋‹ค.

728x90