git reimport
This commit is contained in:
54
archive/2018.10/2018.10.29 - SNCK1B19/MAXPRODU.java
Normal file
54
archive/2018.10/2018.10.29 - SNCK1B19/MAXPRODU.java
Normal file
@@ -0,0 +1,54 @@
|
||||
package chelper;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
import io.InputReader;
|
||||
import io.OutputWriter;
|
||||
import misc.SimpleSavingChelperSolution;
|
||||
|
||||
|
||||
public class MAXPRODU extends SimpleSavingChelperSolution {
|
||||
|
||||
public static final long MOD = 1000000007;
|
||||
|
||||
public void solve(int testNumber, InputReader in, OutputWriter out) {
|
||||
wrapSolve(testNumber, in, out);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void solve(int testNumber) {
|
||||
long n = in.nextLong();
|
||||
long k = in.nextLong();
|
||||
|
||||
if (n < (1 + k) * k / 2) {
|
||||
out.println(-1);
|
||||
return;
|
||||
}
|
||||
|
||||
long[] a = new long[(int) k];
|
||||
|
||||
long next = 1;
|
||||
long left = n;
|
||||
int i = 0;
|
||||
|
||||
while (i < k) {
|
||||
long sum = (next + next + k - i - 1) * (k - i) / 2;
|
||||
if (sum > left) {
|
||||
left -= a[i];
|
||||
i++;
|
||||
continue;
|
||||
}
|
||||
|
||||
a[i] = next;
|
||||
next++;
|
||||
}
|
||||
|
||||
long res = 1;
|
||||
for (long j : a) {
|
||||
res *= (j * j - j) % MOD;
|
||||
res %= MOD;
|
||||
}
|
||||
|
||||
out.println(res);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user