結果
| 問題 | 
                            No.2517 Right Triangles on Circle
                             | 
                    
| コンテスト | |
| ユーザー | 
                             | 
                    
| 提出日時 | 2023-10-27 21:34:57 | 
| 言語 | C++14  (gcc 13.3.0 + boost 1.87.0)  | 
                    
| 結果 | 
                             
                                AC
                                 
                             
                            
                         | 
                    
| 実行時間 | 362 ms / 2,000 ms | 
| コード長 | 338 bytes | 
| コンパイル時間 | 1,751 ms | 
| コンパイル使用メモリ | 176,712 KB | 
| 実行使用メモリ | 24,320 KB | 
| 最終ジャッジ日時 | 2024-09-25 13:39:42 | 
| 合計ジャッジ時間 | 6,880 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge4 / judge2 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 29 | 
ソースコード
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
int main(){
  ll n,m;
  cin>>n>>m;
  vector<ll> a(n);
  for(ll i=0;i<n;i++){
    cin>>a[i];
    a[i]*=2;
  }
  map<ll,ll> mp;
  for(ll i=0;i<n;i++){
    mp[a[i]%m]++;
  }
  ll ans=0;
  for(auto u:mp){
    ll v=u.second;
    ans+=(v*(v-1)/2)*(n-v);
  }
  cout<<ans<<endl;
}