using System; using System.IO; using System.Linq; using System.Collections.Generic; using System.Text; public class Program { public void Proc() { long inpt = long.Parse(Reader.ReadLine()); this.Sheep = inpt; Nullable ans = GetAns(1, inpt); if(ans == null) { Console.WriteLine("NO"); return; } Console.WriteLine("YES"); Console.WriteLine(ans.Value); } private long Sheep; private Nullable GetAns(long min, long max) { if(max-min<=1) { if(GetNum(max)==this.Sheep) { return max; } if(GetNum(min)==this.Sheep) { return min; } return null; } long mid = (max + min) / 2; if(mid.ToString().Length>=10) { return GetAns(min, mid); } decimal midNum = GetNum(mid); if(midNum==Sheep) { return mid; } if(midNum>Sheep) { return GetAns(min, mid); } else { return GetAns(mid, max); } } private decimal GetNum(long n) { decimal tmp = n; return n * (n + 1m) / 2m; } public class Reader { private static StringReader sr; public static bool IsDebug = false; public static string ReadLine() { if (IsDebug) { if (sr == null) { sr = new StringReader(InputText.Trim()); } return sr.ReadLine(); } else { return Console.ReadLine(); } } private static string InputText = @" 2000000000000000000 "; } public static void Main(string[] args) { #if DEBUG Reader.IsDebug = true; #endif Program prg = new Program(); prg.Proc(); } }