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!!!

Please help me!How to solve this problem about it's limited time.
Posted by Hunter 27 Apr 2016 09:46
import java.util.Scanner;

public class Factorials {

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        String k = in.next();
        char a[] = k.toCharArray();
        int length = a.length;
        function(n, length);
        in.close();
    }

    private static void function(int n, int length) {
        int t = n % length;
        int c = (t == 0 ? length : t);
        int sum = n;
        for (int i = 1;; i++) {
            sum = sum * (n - i * length);
            if ((n - i * length) == c) {
                System.out.println(sum);
                break;
            }
        }
    }
}
Re: Please help me!How to solve this problem about it's limited time.
Posted by ToadMonster 27 Apr 2016 10:15
If k > n then answer is n.
Try "5 !!!!!!"