반응형
SMALL
문제
문제풀이
using System;
using System.IO;
namespace BOJ03
{
internal class Program
{
static long sum;
static long N;
static void Main(string[] args)
{
StreamReader sr = new StreamReader(new BufferedStream(Console.OpenStandardInput()));
StreamWriter sw = new StreamWriter(new BufferedStream(Console.OpenStandardOutput()));
long S = long.Parse(Console.ReadLine());
for (long i = 1; i < 4294967295; i++)
{
sum += i;
if (sum > S)
{
N = i-1;
break;
}
}
sw.WriteLine(N);
sr.Close();
sw.Close();
}
}
}
결과창
int 32 가 아닌 long 타입을 사용해야 하는 문제였다.
덕분에 런타임 에러를 경험;;
반응형
LIST
'Algorithm > BOJ' 카테고리의 다른 글
[BOJ] 2864 5와 6의 차이 c# 사용 풀이 (0) | 2023.02.01 |
---|---|
[BOJ] 10162번 전자레인지 C# 사용 풀이 (0) | 2023.02.01 |
[BOJ] 체스판 다시 칠하기 (미해결) - 해결 (0) | 2023.01.31 |
[BOJ] 중복 빼고 정렬하기 C# 사용 풀이 (1) | 2023.01.29 |
[BOJ] 1259번 팰린드롬수 C# 사용 풀이 (0) | 2023.01.26 |