ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1120. Sum of Sequential Numbers

Test # 7 why?
Posted by AlexRad 30 Mar 2015 09:37
What is in test #7 ??

            Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;

            var n = int.Parse(Console.ReadLine().Trim());

            int a = 0;
            var p = (int)Math.Truncate(Math.Sqrt(n + n));
            while (p > 1)
            {
                var s = n - p * (p + 1) / 2;
                if (s >= 0)
                {
                    int rem;
                    a = Math.DivRem(s, p, out rem);
                    if (rem == 0)
                        break;
                }
                p--;
            }
            a++;

            Console.WriteLine("{0} {1}", a, p);
Re: Test # 7 why?
Posted by AlexRad 30 Mar 2015 09:41
I got it!

[code deleted]

Edited by moderator 21.10.2019 23:03