git reimport
This commit is contained in:
97
archive/2019.02/2019.02.26 - GCJPrep/TaskC.java
Normal file
97
archive/2019.02/2019.02.26 - GCJPrep/TaskC.java
Normal file
@@ -0,0 +1,97 @@
|
||||
package chelper;
|
||||
|
||||
import io.InputReader;
|
||||
import io.OutputWriter;
|
||||
import prep.LongMod;
|
||||
import solutions.ChelperSolution;
|
||||
|
||||
|
||||
public class TaskC extends ChelperSolution {
|
||||
|
||||
{
|
||||
gcj = true;
|
||||
}
|
||||
|
||||
public void solve(int testNumber, InputReader in, OutputWriter out) {
|
||||
super.solve(testNumber, in, out);
|
||||
}
|
||||
|
||||
final LongMod MOD = new LongMod(1000000007L);
|
||||
|
||||
int N = 1001000;
|
||||
long[] inverses = new long[N];
|
||||
|
||||
@Override
|
||||
protected void precalc() {
|
||||
for (int i = 2; i < N; i++) {
|
||||
inverses[i] = MOD.inversePrime(i - 1);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void solve(int testNumber) {
|
||||
int n = in.nextInt();
|
||||
int k = in.nextInt();
|
||||
|
||||
long x1 = in.nextInt();
|
||||
long y1 = in.nextInt();
|
||||
long C = in.nextInt();
|
||||
long D = in.nextInt();
|
||||
long E1 = in.nextInt();
|
||||
long E2 = in.nextInt();
|
||||
long FVal = in.nextInt();
|
||||
|
||||
LongMod F = new LongMod(FVal);
|
||||
|
||||
long[] x = new long[n];
|
||||
long[] y = new long[n];
|
||||
|
||||
x[0] = F.mod(x1);
|
||||
y[0] = F.mod(y1);
|
||||
|
||||
for (int i = 1; i < n; i++) {
|
||||
x[i] = F.sum(
|
||||
F.prod(x[i - 1], C),
|
||||
F.prod(y[i - 1], D),
|
||||
E1
|
||||
);
|
||||
y[i] = F.sum(
|
||||
F.prod(x[i - 1], D),
|
||||
F.prod(y[i - 1], C),
|
||||
E2
|
||||
);
|
||||
}
|
||||
|
||||
long[] a = new long[n];
|
||||
for (int i = 0; i < n; i++) {
|
||||
a[i] = F.sum(x[i], y[i]);
|
||||
}
|
||||
|
||||
long[] numPowers = new long[n + 1];
|
||||
numPowers[1] = MOD.mod(k);
|
||||
for (int i = 2; i <= n; i++) {
|
||||
numPowers[i] = MOD.prod(
|
||||
i,
|
||||
MOD.sub(MOD.pow(i, k), 1),
|
||||
inverses[i]
|
||||
);
|
||||
}
|
||||
|
||||
long res = 0;
|
||||
long numSum = 0;
|
||||
for (int i = 0; i < n; i++) {
|
||||
numSum = MOD.sum(numSum, numPowers[i + 1]);
|
||||
res = MOD.sum(
|
||||
res,
|
||||
MOD.prod(
|
||||
a[i],
|
||||
n - i,
|
||||
numSum
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
debug.println("hi");
|
||||
out.println(res);
|
||||
}
|
||||
}
|
42
archive/2019.02/2019.02.26 - GCJPrep/TaskC.json
Normal file
42
archive/2019.02/2019.02.26 - GCJPrep/TaskC.json
Normal file
@@ -0,0 +1,42 @@
|
||||
{
|
||||
"name" : "TaskC",
|
||||
"testType" : "MULTI_NUMBER",
|
||||
"input" : {
|
||||
"type" : "STANDARD",
|
||||
"fileName" : "input.txt"
|
||||
},
|
||||
"output" : {
|
||||
"type" : "STANDARD",
|
||||
"fileName" : "output.txt"
|
||||
},
|
||||
"tests" : [ {
|
||||
"input" : "2\n2 3 1 2 1 2 1 1 9\n10 10 10001 10002 10003 10004 10005 10006 89273\n",
|
||||
"output" : "Case #1: 52\nCase #2: 739786670\n",
|
||||
"index" : 0,
|
||||
"active" : true
|
||||
}, {
|
||||
"input" : "2\n2 1 1 2 1 2 1 1 9\n10 1 10001 10002 10003 10004 10005 10006 89273\n",
|
||||
"index" : 1,
|
||||
"active" : true
|
||||
}, {
|
||||
"input" : "10\n1000000 1000 1 2 1 2 1 1 9\n1000000 1000 1 2 1 2 1 1 9\n1000000 1000 1 2 1 2 1 1 9\n1000000 1000 1 2 1 2 1 1 9\n1000000 1000 1 2 1 2 1 1 9\n1000000 1000 1 2 1 2 1 1 9\n1000000 1000 1 2 1 2 1 1 9\n1000000 1000 1 2 1 2 1 1 9\n1000000 1000 1 2 1 2 1 1 9\n1000000 1000 1 2 1 2 1 1 9\n",
|
||||
"index" : 2,
|
||||
"active" : true
|
||||
} ],
|
||||
"location" : "src/chelper",
|
||||
"vmArgs" : "-Xmx256m -Xss64m",
|
||||
"mainClass" : "Main",
|
||||
"taskClass" : "chelper.TaskC",
|
||||
"checkerClass" : "net.egork.chelper.checkers.TokenChecker",
|
||||
"checkerParameters" : "",
|
||||
"testClasses" : [ ],
|
||||
"date" : "2019.02.26",
|
||||
"contestName" : "GCJPrep",
|
||||
"truncate" : true,
|
||||
"inputClass" : "io.InputReader",
|
||||
"outputClass" : "io.OutputWriter",
|
||||
"includeLocale" : false,
|
||||
"failOnOverflow" : false,
|
||||
"interactive" : false,
|
||||
"interactor" : "net.egork.chelper.tester.Interactor"
|
||||
}
|
Reference in New Issue
Block a user