백준

백준 15894번 c#

대왕군 2024. 2. 2. 14:56

 

using System;

namespace Baekjoon
{
    internal class Program
    {
        static void Main(string[] args)
        {
            //그냥 콘솔창 예쁘게 꾸미는 코드(심심해서 넣음)
            Console.BackgroundColor = ConsoleColor.DarkCyan;;

            //1에서 100억의 정수가 들어간다는 사실에 주의
            //int.Parse가 아닌 long.Parse를 써준다
            Console.WriteLine(long.Parse(Console.ReadLine()) * 4);
        }

    }
}

 

공식자체는 쉬워서 당연히 한번에 맞출거라고 생각했지만 함정이 있었다

 

함정은 바로 입력값이 100억까지란 것이었고

int의 범위는 -2,147,483,648 ~ 2,147,483,647이다

 

범위를 늘려주기 위해 long형을 써서 해결했다.

'백준' 카테고리의 다른 글

백준 10101번 c#  (0) 2024.02.02
백준 9063번 c#  (0) 2024.02.02
백준 3009번 c#  (0) 2024.02.01
백준 1085번 c#  (0) 2024.02.01
백준 27323번 c#  (0) 2024.02.01