結果
問題 | No.1041 直線大学 |
ユーザー | silviasetitech |
提出日時 | 2020-05-13 20:28:48 |
言語 | Java21 (openjdk 21) |
結果 |
WA
|
実行時間 | - |
コード長 | 2,964 bytes |
コンパイル時間 | 2,418 ms |
コンパイル使用メモリ | 79,860 KB |
実行使用メモリ | 45,332 KB |
最終ジャッジ日時 | 2024-09-14 15:38:42 |
合計ジャッジ時間 | 9,847 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 133 ms
41,332 KB |
testcase_01 | AC | 135 ms
41,112 KB |
testcase_02 | AC | 122 ms
39,996 KB |
testcase_03 | AC | 137 ms
41,460 KB |
testcase_04 | AC | 137 ms
41,288 KB |
testcase_05 | AC | 134 ms
40,964 KB |
testcase_06 | AC | 139 ms
41,084 KB |
testcase_07 | AC | 145 ms
41,452 KB |
testcase_08 | WA | - |
testcase_09 | AC | 141 ms
41,456 KB |
testcase_10 | AC | 169 ms
43,980 KB |
testcase_11 | AC | 170 ms
44,156 KB |
testcase_12 | AC | 183 ms
44,040 KB |
testcase_13 | AC | 149 ms
41,808 KB |
testcase_14 | WA | - |
testcase_15 | AC | 150 ms
42,232 KB |
testcase_16 | AC | 171 ms
44,380 KB |
testcase_17 | WA | - |
testcase_18 | AC | 155 ms
43,216 KB |
testcase_19 | WA | - |
testcase_20 | AC | 132 ms
41,112 KB |
testcase_21 | AC | 155 ms
43,208 KB |
testcase_22 | AC | 134 ms
41,452 KB |
testcase_23 | AC | 190 ms
45,156 KB |
testcase_24 | WA | - |
testcase_25 | AC | 153 ms
43,704 KB |
testcase_26 | AC | 141 ms
41,684 KB |
testcase_27 | AC | 144 ms
42,148 KB |
testcase_28 | AC | 133 ms
41,616 KB |
testcase_29 | AC | 134 ms
41,300 KB |
testcase_30 | AC | 132 ms
41,608 KB |
testcase_31 | AC | 135 ms
41,284 KB |
testcase_32 | AC | 130 ms
41,292 KB |
testcase_33 | AC | 118 ms
39,848 KB |
testcase_34 | AC | 118 ms
39,972 KB |
testcase_35 | AC | 132 ms
41,476 KB |
testcase_36 | AC | 134 ms
41,208 KB |
testcase_37 | AC | 119 ms
41,160 KB |
testcase_38 | AC | 183 ms
44,908 KB |
testcase_39 | AC | 146 ms
42,260 KB |
ソースコード
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.Objects; import java.util.Scanner; /** * Built using CHelper plug-in * Actual solution is at the top * * @author silviase */ public class Main { public static void main(String[] args) { InputStream inputStream = System.in; OutputStream outputStream = System.out; Scanner in = new Scanner(inputStream); PrintWriter out = new PrintWriter(outputStream); ChokusenUniv solver = new ChokusenUniv(); solver.solve(1, in, out); out.close(); } static class ChokusenUniv { public void solve(int testNumber, Scanner in, PrintWriter out) { int n = in.nextInt(); Vec2i[] v = new Vec2i[n]; int max = 2; for (int i = 0; i < n; i++) { v[i] = new Vec2i(in.nextInt(), in.nextInt()); } for (int i = 0; i < n; i++) { for (int j = i + 1; j < n; j++) { // i-> j int cnt = 0; Vec2i dif = new Vec2i(v[i].x - v[i + 1].x, v[i].y - v[i + 1].y); int gcd = (int) MathUtil.gcd(Math.abs(dif.x), Math.abs(dif.y)); dif.x /= gcd; dif.y /= gcd; for (int k = 0; k < n; k++) { Vec2i diff = new Vec2i(v[k].x - v[i].x, v[k].y - v[i].y); if (dif.x == 0) { if (diff.x == 0) cnt++; continue; } if (dif.y == 0) { if (diff.y == 0) cnt++; continue; } if (diff.x / dif.x == diff.y / dif.y && diff.x % dif.x == 0 && diff.y % dif.y == 0) cnt++; } max = Math.max(max, cnt); } } out.println(max); } } static class MathUtil { public static long gcd(long a, long b) { if (b == 0) return a; return a % b == 0 ? b : gcd(b, a % b); } } static class Vec2i { public int x; public int y; public Vec2i(int x, int y) { this.x = x; this.y = y; } public String toString() { return "Vec2i{" + "x=" + x + ", y=" + y + '}'; } public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; Vec2i vec2i = (Vec2i) o; return x == vec2i.x && y == vec2i.y; } public int hashCode() { return Objects.hash(x, y); } } }