|  | 
|  | 
| back to board | Please help  me!How to solve this problem about it's limited time. Posted by Hunter  27 Apr 2016 09:46import 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. If k > n then answer is n.Try "5 !!!!!!"
 | 
 | 
|