Algorithm/BOJ
C#) [BOJ] 2292 벌집 ★
HSH12345
2023. 1. 25. 22:19
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
namespace _01
{
class Program
{
static void Main(string[] args)
{
StreamReader sr = new StreamReader(Console.OpenStandardInput());
StreamWriter sw = new StreamWriter(Console.OpenStandardOutput());
int N = int.Parse(sr.ReadLine());
int cnt = 1; //첫 번째 방
int range = 1; //찾는 수의 범위 체크(1 / 6 * 1 / 6 * 2 / 6 * 3 /...)
int tmp = 1; //첫 번째 방부터 시작
while (true)
{
if (range >= N) break; //레인지를 6 * cnt 만큼 증가시켜 N이 속하는 구간에서 멈춤
tmp = 6 * (cnt++);
range += tmp;
}
sw.WriteLine(cnt);
sr.Close();
sw.Close();
}
}
}
수학적 규칙은 종종와서 봐야될 듯...