class A {
public static void main
(String[] args
) { int n = 10000;
int g[][] = new int[n][n];
long st, en;
// one
for(int i = 0; i < n; i++) {
for(int j = 0; j < n; j++) {
g[i][j] = i + j;
}
}
System.
out.
println("\nTwo time " + (en
- st
)/1000000.
d + " msc");
// two
for(int i = 0; i < n; i++) {
g[i][i] = i + i;
for(int j = 0; j < i; j++) {
g[j][i] = g[i][j] = i + j;
}
}
System.
out.
println("\nTwo time " + (en
- st
)/1000000.
d + " msc");
for (int i = 0; i < n; i++) {
g[i][i] = i << 1;
for (int j = i + 1; j < n; j++) {
g[i][j] = i + j;
}
}
for (int i = 1; i < n; i++) {
System.
arraycopy(g
[i
-1],
1, g
[i
],
0, i
); }
System.
out.
println("\nThree time " + (en
- st
) / 1000000.
d + " msc"); }
}
Y2xhc3MgQSB7CiAgcHVibGljIHN0YXRpYyB2b2lkIG1haW4oU3RyaW5nW10gYXJncykgewogICAgaW50IG4gPSAxMDAwMDsKCiAgICBpbnQgZ1tdW10gPSBuZXcgaW50W25dW25dOwogICAgbG9uZyBzdCwgZW47CgogICAgLy8gb25lCiAgICBzdCA9IFN5c3RlbS5uYW5vVGltZSgpOwogICAgZm9yKGludCBpID0gMDsgaSA8IG47IGkrKykgewogICAgICBmb3IoaW50IGogPSAwOyBqIDwgbjsgaisrKSB7CiAgICAgICAgZ1tpXVtqXSA9IGkgKyBqOyAKICAgICAgfQogICAgfQogICAgZW4gPSBTeXN0ZW0ubmFub1RpbWUoKTsKICAgIFN5c3RlbS5vdXQucHJpbnRsbigiXG5Ud28gdGltZSAiICsgKGVuIC0gc3QpLzEwMDAwMDAuZCArICIgbXNjIik7CgogICAgLy8gdHdvCiAgICBzdCA9IFN5c3RlbS5uYW5vVGltZSgpOwogICAgZm9yKGludCBpID0gMDsgaSA8IG47IGkrKykgewogICAgICBnW2ldW2ldID0gIGkgKyBpOwogICAgICBmb3IoaW50IGogPSAwOyBqIDwgaTsgaisrKSB7CiAgICAgICAgZ1tqXVtpXSA9IGdbaV1bal0gPSBpICsgajsgCiAgICAgIH0KICAgIH0KICAgIGVuID0gU3lzdGVtLm5hbm9UaW1lKCk7CiAgICBTeXN0ZW0ub3V0LnByaW50bG4oIlxuVHdvIHRpbWUgIiArIChlbiAtIHN0KS8xMDAwMDAwLmQgKyAiIG1zYyIpOwogICAgCiAgICBzdCA9IFN5c3RlbS5uYW5vVGltZSgpOwogICAgICAgIGZvciAoaW50IGkgPSAwOyBpIDwgbjsgaSsrKSB7CiAgICAgICAgICAgIGdbaV1baV0gPSBpIDw8IDE7CiAgICAgICAgICAgIGZvciAoaW50IGogPSBpICsgMTsgaiA8IG47IGorKykgewogICAgICAgICAgICAgICAgZ1tpXVtqXSA9IGkgKyBqOwogICAgICAgICAgICB9CiAgICAgICAgfQogICAgICAgIGZvciAoaW50IGkgPSAxOyBpIDwgbjsgaSsrKSB7CiAgICAgICAgICAgIFN5c3RlbS5hcnJheWNvcHkoZ1tpLTFdLCAxLCBnW2ldLCAwLCBpKTsKICAgICAgICB9CiAgICAgICAgZW4gPSBTeXN0ZW0ubmFub1RpbWUoKTsKICAgICAgICBTeXN0ZW0ub3V0LnByaW50bG4oIlxuVGhyZWUgdGltZSAiICsgKGVuIC0gc3QpIC8gMTAwMDAwMC5kICsgIiBtc2MiKTsKICB9Cn0=