結果
| 問題 |
No.9002 FizzBuzz(テスト用)
|
| ユーザー |
|
| 提出日時 | 2017-06-02 17:22:33 |
| 言語 | Java (openjdk 23) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 2,676 bytes |
| コンパイル時間 | 3,895 ms |
| コンパイル使用メモリ | 83,444 KB |
| 実行使用メモリ | 84,980 KB |
| 最終ジャッジ日時 | 2024-09-21 22:15:30 |
| 合計ジャッジ時間 | 14,824 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | WA * 4 |
ソースコード
import java.util.Random;
import java.util.function.LongFunction;
import java.util.function.Consumer;
import java.util.function.LongFunction;
import java.util.Arrays;
public class Main {
public static class BenchUtils {
public static <T> Stat bench(LongFunction<T> generator, Consumer<T> runner, int rep)
{
long sum = 0, max = 0, min = Long.MAX_VALUE;
for(int i = 0;i < rep;i++){
T t = generator.apply(i*1000000009L);
long S = System.nanoTime();
runner.accept(t);
long G = System.nanoTime();
sum += G-S;
max = Math.max(max, G-S);
min = Math.min(min, G-S);
}
return new Stat(sum, sum/rep, max, min);
}
}
static class TestCase
{
long[] a, b;
public TestCase(long[] a, long[] b) {
this.a = a;
this.b = b;
}
}
public static class Stat {
public long sum;
public long average;
public long max;
public long min;
public Stat(long sum, long average, long max, long min) {
this.sum = sum;
this.average = average;
this.max = max;
this.min = min;
}
@Override
public String toString() {
return "Stat [sum=" + sum + ", average=" + average + ", max=" + max + ", min=" + min + "]";
}
}
public static class U {
public static void tr(Object... o) { System.out.println(Arrays.deepToString(o)); }
}
public static void main(String[] args) {
LongFunction<TestCase> generator = (o) -> {
Random gen = new Random(o*1000000009L);
long[] a = new long[1000000];
long[] b = new long[1000000];
for(int i = 0;i < a.length;i++)a[i] = gen.nextInt(1000000007);
for(int i = 0;i < b.length;i++)b[i] = gen.nextInt(1000000007);
return new TestCase(a, b);
};
// divide %
U.tr(BenchUtils.bench(generator, (t) -> {
int mod = 1000000007;
for(int i = 0;i < t.a.length;i++){
t.a[i] += t.b[i];
}
for(int i = 0;i < t.a.length;i++){
t.a[i] %= mod;
}
}, 10));
// concat %
U.tr(BenchUtils.bench(generator, (t) -> {
int mod = 1000000007;
for(int i = 0;i < t.a.length;i++){
t.a[i] += t.b[i];
t.a[i] %= mod;
}
}, 10));
// concat %2
U.tr(BenchUtils.bench(generator, (t) -> {
int mod = 1000000007;
for(int i = 0;i < t.a.length;i++){
t.a[i] = (t.a[i] + t.b[i]) % mod;
}
}, 10));
// divide -
U.tr(BenchUtils.bench(generator, (t) -> {
int mod = 1000000007;
for(int i = 0;i < t.a.length;i++){
t.a[i] += t.b[i];
}
for(int i = 0;i < t.a.length;i++){
if(t.a[i] >= mod)t.a[i] -= mod;
}
}, 10));
// concat -
U.tr(BenchUtils.bench(generator, (t) -> {
int mod = 1000000007;
for(int i = 0;i < t.a.length;i++){
t.a[i] += t.b[i];
if(t.a[i] >= mod)t.a[i] -= mod;
}
}, 10));
}
}