BaekJoon[C#]

기본 수학 1단계 10757

wny0320 2022. 10. 21. 08:57

백준 온라인 코딩 문제풀이

https://www.acmicpc.net/

 

Baekjoon Online Judge

Baekjoon Online Judge 프로그래밍 문제를 풀고 온라인으로 채점받을 수 있는 곳입니다.

www.acmicpc.net

 

코드 참고

https://replit.com/@wny0320

 

wny0320 (박 상운)

Run code live in your browser. Write and run code in 50+ languages online with Replit, a powerful IDE, compiler, & interpreter.

replit.com

 

10757에 대해 다룸

 


10757

using System;
using System.Numerics;
class Program
{
    static void Main(string[] args)
    {
        string[] input = Console.ReadLine().Split();
        BigInteger a = BigInteger.Parse(input[0]);
        BigInteger b = BigInteger.Parse(input[1]);
        Console.WriteLine(a+b);
    }
}

C#에서는 천문학적인 숫자를 사용하기 위한 BigInteger를 System.Numberics 라이브러리에서 제공함

 

단점은 메모리를 잡아먹는 하마라는것

 

참고

https://learntutorials.net/ko/csharp/topic/5654/biginteger

 

C# Language => BigInteger

Learn c# - BigInteger

learntutorials.net

 

그리고 이 방식 외에 다른 방식으로는 각각의 수를 String[] 형태로 저장하여 각 자리수마다 계산하는 방식으로도 해결이 가능하나 브론즈 5의 난이도인걸 감안하였을 때 맞는 자료형을 찾는 것이 난이도에 맞는것 같음

'BaekJoon[C#]' 카테고리의 다른 글

기본 수학 2단계 2581  (0) 2022.10.29
기본 수학 2단계 1978  (0) 2022.10.28
기본 수학 1단계 2839  (0) 2022.10.20
기본 수학 1단계 10250  (0) 2022.10.12
기본 수학 1단계 2869  (0) 2022.10.10