結果
問題 |
No.2517 Right Triangles on Circle
|
ユーザー |
![]() |
提出日時 | 2023-10-30 11:45:16 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 73 ms / 2,000 ms |
コード長 | 745 bytes |
コンパイル時間 | 352 ms |
コンパイル使用メモリ | 45,128 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-09-25 17:12:16 |
合計ジャッジ時間 | 2,492 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 29 |
ソースコード
/* -*- coding: utf-8 -*- * * 2517.cc: No.2517 Right Triangles on Circle - yukicoder */ #include<cstdio> #include<algorithm> using namespace std; /* constant */ const int MAX_N = 300000; /* typedef */ typedef long long ll; /* global variables */ int as[MAX_N * 2]; /* subroutines */ /* main */ int main() { int n, m; scanf("%d%d", &n, &m); for (int i = 0; i < n; i++) scanf("%d", as + i), as[i] %= m; if (m & 1) { puts("0"); return 0; } int h = m / 2, n2 = n * 2; sort(as, as + n); for (int i = 0; i < n; i++) as[n + i] = m + as[i]; ll sum = 0; for (int i = 0, j = 0; i < n; i++) { while (as[j] - as[i] < h) j++; if (as[j] - as[i] == h) sum += n - 2; } printf("%lld\n", sum / 2); return 0; }