git reimport
This commit is contained in:
44
archive/2017.04/2017.04.16 - unsorted/TaskA.java
Normal file
44
archive/2017.04/2017.04.16 - unsorted/TaskA.java
Normal file
@@ -0,0 +1,44 @@
|
||||
package chelper;
|
||||
|
||||
import io.InputReader;
|
||||
import io.OutputWriter;
|
||||
import misc.SimpleSavingChelperSolution;
|
||||
|
||||
|
||||
public class TaskA extends SimpleSavingChelperSolution {
|
||||
|
||||
public void solve(int testNumber, InputReader in, OutputWriter out) {
|
||||
wrapSolve(testNumber, in, out);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void solve(int testNumber) {
|
||||
int n = in.nextInt();
|
||||
int m = in.nextInt();
|
||||
|
||||
int[][] a = new int[n][m];
|
||||
|
||||
int c = 1;
|
||||
|
||||
for (int i = 0; i < 100; i++) {
|
||||
for (int j = 0; j < 100; j++) {
|
||||
int x = i - j;
|
||||
int y = j;
|
||||
|
||||
if (x < 0 || y < 0 || x >= n || y >= m) {
|
||||
continue;
|
||||
}
|
||||
|
||||
a[x][y] = c;
|
||||
c++;
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < n; i++) {
|
||||
for (int j = 0; j < m; j++) {
|
||||
out.print(a[n - 1 - i][m - 1 - j] + " ");
|
||||
}
|
||||
out.println();
|
||||
}
|
||||
}
|
||||
}
|
31
archive/2017.04/2017.04.16 - unsorted/TaskA.task
Normal file
31
archive/2017.04/2017.04.16 - unsorted/TaskA.task
Normal file
@@ -0,0 +1,31 @@
|
||||
5 TaskA
|
||||
12 MULTI_NUMBER
|
||||
8 STANDARD
|
||||
9 input.txt
|
||||
8 STANDARD
|
||||
10 output.txt
|
||||
1
|
||||
0
|
||||
9 2
|
||||
2 3
|
||||
3 2
|
||||
27 6 4 2
|
||||
5 3 1
|
||||
6 4
|
||||
5 2
|
||||
3 1
|
||||
1
|
||||
11 src/chelper
|
||||
16 -Xmx256m -Xss64m
|
||||
4 Main
|
||||
13 chelper.TaskA
|
||||
39 net.egork.chelper.checkers.TokenChecker
|
||||
0
|
||||
0
|
||||
10 2017.04.16
|
||||
0
|
||||
1
|
||||
14 io.InputReader
|
||||
15 io.OutputWriter
|
||||
0
|
||||
0
|
176
archive/2017.04/2017.04.16 - unsorted/TaskB.java
Normal file
176
archive/2017.04/2017.04.16 - unsorted/TaskB.java
Normal file
@@ -0,0 +1,176 @@
|
||||
package chelper;
|
||||
|
||||
import java.math.BigInteger;
|
||||
|
||||
import io.InputReader;
|
||||
import io.OutputWriter;
|
||||
import misc.SimpleSavingChelperSolution;
|
||||
import misc.Stuff;
|
||||
|
||||
|
||||
public class TaskB extends SimpleSavingChelperSolution {
|
||||
|
||||
static class Fraction implements Comparable<Fraction> {
|
||||
public final long a;
|
||||
public final long b;
|
||||
|
||||
public Fraction(long a, long b) {
|
||||
if (b < 0) {
|
||||
a *= -1;
|
||||
b *= -1;
|
||||
}
|
||||
|
||||
if (b == 0) {
|
||||
throw new IllegalArgumentException();
|
||||
}
|
||||
|
||||
if (a == 0) {
|
||||
this.a = 0;
|
||||
this.b = 1;
|
||||
return;
|
||||
}
|
||||
|
||||
long g = Math.abs(Stuff.gcd(a, b));
|
||||
this.a = a / g;
|
||||
this.b = b / g;
|
||||
}
|
||||
|
||||
public Fraction add(Fraction o) {
|
||||
return new Fraction(a * o.b + o.a * b, b * o.b);
|
||||
}
|
||||
|
||||
public Fraction negate() {
|
||||
return new Fraction(-a, b);
|
||||
}
|
||||
|
||||
public Fraction subtract(Fraction o) {
|
||||
return add(o.negate());
|
||||
}
|
||||
|
||||
public Fraction multiply(Fraction o) {
|
||||
return new Fraction(a * o.a, b * o.b);
|
||||
}
|
||||
|
||||
public Fraction inverse() {
|
||||
return new Fraction(b, a);
|
||||
}
|
||||
|
||||
public Fraction divide(Fraction o) {
|
||||
return multiply(o.inverse());
|
||||
}
|
||||
|
||||
public boolean isDivisibleBy(Fraction o) {
|
||||
Fraction d = divide(o);
|
||||
return d.b == 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(Fraction o) {
|
||||
Fraction d = subtract(o);
|
||||
return Long.compare(d.a, 0);
|
||||
}
|
||||
|
||||
public static Fraction gcd(Fraction a, Fraction b) {
|
||||
if (a.compareTo(b) < 0) {
|
||||
Fraction t = a;
|
||||
a = b;
|
||||
b = t;
|
||||
}
|
||||
|
||||
if (a.isDivisibleBy(b)) {
|
||||
return b;
|
||||
}
|
||||
|
||||
return gcd(a.subtract(b), b);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return a + " " + b;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
|
||||
Fraction fraction = (Fraction) o;
|
||||
|
||||
if (a != fraction.a) return false;
|
||||
return b == fraction.b;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result = (int) (a ^ a >>> 32);
|
||||
result = 31 * result + (int) (b ^ b >>> 32);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
public void solve(int testNumber, InputReader in, OutputWriter out) {
|
||||
wrapSolve(testNumber, in, out);
|
||||
}
|
||||
|
||||
public static BigInteger gcd(BigInteger a, BigInteger b) {
|
||||
if (a.equals(BigInteger.ZERO) || b.equals(BigInteger.ZERO)) {
|
||||
return a.max(b);
|
||||
}
|
||||
|
||||
while (!a.mod(b).equals(BigInteger.ZERO)) {
|
||||
a = a.mod(b);
|
||||
BigInteger t = a;
|
||||
a = b;
|
||||
b = t;
|
||||
}
|
||||
|
||||
return b;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void solve(int testNumber) {
|
||||
long M = 100;
|
||||
|
||||
// System.out.println(new Fraction(((long) (Math.random() * M)), ((long) (Math.random() * M))));
|
||||
// System.out.println(new Fraction(((long) (Math.random() * M)), ((long) (Math.random() * M))));
|
||||
// System.out.println(new Fraction(((long) (Math.random() * M)), ((long) (Math.random() * M))));
|
||||
// System.out.println(new Fraction(((long) (Math.random() * M)), ((long) (Math.random() * M))));
|
||||
// System.out.println(new Fraction(((long) (Math.random() * M)), ((long) (Math.random() * M))));
|
||||
// System.out.println(new Fraction(((long) (Math.random() * M)), ((long) (Math.random() * M))));
|
||||
// System.out.println(new Fraction(((long) (Math.random() * M)), ((long) (Math.random() * M))));
|
||||
// System.out.println(new Fraction(((long) (Math.random() * M)), ((long) (Math.random() * M))));
|
||||
|
||||
|
||||
Fraction a = new Fraction(in.nextInt(), in.nextInt());
|
||||
Fraction b = new Fraction(in.nextInt(), in.nextInt());
|
||||
|
||||
// Fraction g = Fraction.gcd(a, b);
|
||||
//
|
||||
// Fraction ans1 = a.multiply(b).divide(g);
|
||||
// out.println(ans1);
|
||||
|
||||
BigInteger aa = BigInteger.valueOf(a.a);
|
||||
BigInteger ab = BigInteger.valueOf(a.b);
|
||||
BigInteger ba = BigInteger.valueOf(b.a);
|
||||
BigInteger bb = BigInteger.valueOf(b.b);
|
||||
|
||||
BigInteger bg = gcd(ab, bb);
|
||||
BigInteger b1 = ab.multiply(bb).divide(bg);
|
||||
BigInteger a1 = b1.divide(ab).multiply(aa);
|
||||
BigInteger a2 = b1.divide(bb).multiply(ba);
|
||||
BigInteger ag = gcd(a1, a2);
|
||||
BigInteger lcm = a1.multiply(a2).divide(ag);
|
||||
|
||||
BigInteger g = gcd(lcm, b1);
|
||||
BigInteger ar = lcm.divide(g);
|
||||
BigInteger br = b1.divide(g);
|
||||
|
||||
out.println(ar + " " + br);
|
||||
|
||||
// if (!ans1.equals(ans2)) {
|
||||
// throw new RuntimeException();
|
||||
// }
|
||||
}
|
||||
}
|
56
archive/2017.04/2017.04.16 - unsorted/TaskB.task
Normal file
56
archive/2017.04/2017.04.16 - unsorted/TaskB.task
Normal file
@@ -0,0 +1,56 @@
|
||||
5 TaskB
|
||||
12 MULTI_NUMBER
|
||||
8 STANDARD
|
||||
9 input.txt
|
||||
8 STANDARD
|
||||
10 output.txt
|
||||
4
|
||||
0
|
||||
21 2
|
||||
9 5 12 5
|
||||
1 10 3 100
|
||||
9 36 5
|
||||
3 10
|
||||
1
|
||||
1
|
||||
14 1
|
||||
1 100
|
||||
1 1000
|
||||
-1
|
||||
1
|
||||
2
|
||||
125 3
|
||||
38476513 2037278746
|
||||
553939120 1479775151
|
||||
78983548 165294827
|
||||
1855049790 771139337
|
||||
1386417042 1807485049
|
||||
492281701 1685084932
|
||||
-1
|
||||
1
|
||||
3
|
||||
45 4
|
||||
7 5
|
||||
13 16
|
||||
64 13
|
||||
86 13
|
||||
9 14
|
||||
2 13
|
||||
16 11
|
||||
52 75
|
||||
-1
|
||||
1
|
||||
11 src/chelper
|
||||
16 -Xmx256m -Xss64m
|
||||
4 Main
|
||||
13 chelper.TaskB
|
||||
39 net.egork.chelper.checkers.TokenChecker
|
||||
0
|
||||
0
|
||||
10 2017.04.16
|
||||
0
|
||||
1
|
||||
14 io.InputReader
|
||||
15 io.OutputWriter
|
||||
0
|
||||
0
|
Reference in New Issue
Block a user