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 1083. Factorials!!!

C# Solution
Posted by Serge 13 Jan 2018 17:55
//Don't ask me. I don't know. Just work. If anybody can tell me why   for (int i = k + 7; i >= 0; i--)   and why we needn't n%k - Please, tell! I don't understand.

using System;

namespace ConsoleApp32
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] vvod = Console.In.ReadLine().Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
            int n = int.Parse(vvod[0]);
            string k1 = vvod[1];
            int k = k1.Length;
            int q = 1;

            for (int i = k + 7; i >= 0; i--)
                {
                    int t;
                    t = n - i * k;
                    if (t > 0) q *= t;
                }
            Console.WriteLine(q);
        }
    }
}

Edited by author 13.01.2018 23:49
Re: C# Solution
Posted by Andre Marin 19 Mar 2023 18:48
because we have more than 1x! (minimum 2) and less or exactly 9 (because we have 9 numbers 2...10 and it nevermind if we have more !...! than 9).
so we have k = 9-2 =7 (maximum)
if we use % and the number of '!' is > 10 we have wrong answer, because we have zero: x%y=0

Edited by author 19.03.2023 19:49