結果

問題 No.2517 Right Triangles on Circle
ユーザー ks2mks2m
提出日時 2023-10-27 21:31:09
言語 Java21
(openjdk 21)
結果
AC  
実行時間 620 ms / 2,000 ms
コード長 863 bytes
コンパイル時間 7,736 ms
コンパイル使用メモリ 77,352 KB
実行使用メモリ 106,104 KB
最終ジャッジ日時 2023-10-27 21:31:35
合計ジャッジ時間 13,682 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 56 ms
53,244 KB
testcase_01 AC 54 ms
53,236 KB
testcase_02 AC 54 ms
53,248 KB
testcase_03 AC 54 ms
53,244 KB
testcase_04 AC 54 ms
53,248 KB
testcase_05 AC 55 ms
53,252 KB
testcase_06 AC 55 ms
53,264 KB
testcase_07 AC 55 ms
53,248 KB
testcase_08 AC 55 ms
53,244 KB
testcase_09 AC 57 ms
53,268 KB
testcase_10 AC 55 ms
51,340 KB
testcase_11 AC 54 ms
53,248 KB
testcase_12 AC 54 ms
53,240 KB
testcase_13 AC 592 ms
103,480 KB
testcase_14 AC 481 ms
94,024 KB
testcase_15 AC 620 ms
105,848 KB
testcase_16 AC 607 ms
106,104 KB
testcase_17 AC 520 ms
91,684 KB
testcase_18 AC 533 ms
95,332 KB
testcase_19 AC 461 ms
84,448 KB
testcase_20 AC 494 ms
84,740 KB
testcase_21 AC 584 ms
103,568 KB
testcase_22 AC 252 ms
65,692 KB
testcase_23 AC 470 ms
87,732 KB
testcase_24 AC 317 ms
69,620 KB
testcase_25 AC 247 ms
65,496 KB
testcase_26 AC 555 ms
102,200 KB
testcase_27 AC 273 ms
65,524 KB
testcase_28 AC 220 ms
63,356 KB
testcase_29 AC 313 ms
69,112 KB
testcase_30 AC 238 ms
65,872 KB
testcase_31 AC 512 ms
89,244 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.HashSet;
import java.util.Set;

public class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] sa = br.readLine().split(" ");
		int n = Integer.parseInt(sa[0]);
		int m = Integer.parseInt(sa[1]);
		sa = br.readLine().split(" ");
		int[] a = new int[n];
		Set<Integer> set = new HashSet<>();
		for (int i = 0; i < n; i++) {
			a[i] = Integer.parseInt(sa[i]);
			set.add(a[i]);
		}
		br.close();

		if (m % 2 == 1) {
			System.out.println(0);
			return;
		}

		long ans = 0;
		int m2 = m / 2;
		for (int i = 0; i < n; i++) {
			int v = a[i] + m2;
			v %= m;
			if (v == 0) {
				v = m;
			}
			if (set.contains(v)) {
				ans += n - 2;
			}
		}
		System.out.println(ans / 2);
	}
}
0