結果

問題 No.2260 Adic Sum
ユーザー kotatsugamekotatsugame
提出日時 2023-04-09 06:05:26
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 159 ms / 2,000 ms
コード長 465 bytes
コンパイル時間 918 ms
コンパイル使用メモリ 81,596 KB
実行使用メモリ 14,224 KB
最終ジャッジ日時 2024-04-16 00:01:55
合計ジャッジ時間 4,315 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 2 ms
5,376 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 AC 3 ms
5,376 KB
testcase_09 AC 3 ms
5,376 KB
testcase_10 AC 3 ms
5,376 KB
testcase_11 AC 2 ms
5,376 KB
testcase_12 AC 3 ms
5,376 KB
testcase_13 AC 4 ms
5,376 KB
testcase_14 AC 46 ms
7,936 KB
testcase_15 AC 74 ms
9,596 KB
testcase_16 AC 38 ms
7,296 KB
testcase_17 AC 89 ms
9,856 KB
testcase_18 AC 86 ms
5,376 KB
testcase_19 AC 92 ms
5,376 KB
testcase_20 AC 81 ms
5,376 KB
testcase_21 AC 84 ms
5,376 KB
testcase_22 AC 78 ms
5,376 KB
testcase_23 AC 71 ms
5,376 KB
testcase_24 AC 91 ms
5,376 KB
testcase_25 AC 149 ms
13,696 KB
testcase_26 AC 148 ms
13,568 KB
testcase_27 AC 159 ms
14,224 KB
testcase_28 AC 151 ms
13,696 KB
testcase_29 AC 151 ms
13,884 KB
testcase_30 AC 75 ms
5,888 KB
testcase_31 AC 101 ms
9,652 KB
testcase_32 AC 100 ms
9,752 KB
testcase_33 AC 59 ms
5,376 KB
testcase_34 AC 59 ms
5,376 KB
testcase_35 AC 110 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<vector>
#include<map>
using namespace std;
int P;
long ans;
void solve(const vector<int>&A)
{
	if(A.size()<=1)return;
	map<int,vector<int> >mp;
	for(int i=0;i<A.size();i++)mp[A[i]%P].push_back(A[i]/P);
	for(auto it=mp.begin();it!=mp.end();it++)
	{
		int n=it->second.size();
		ans+=(long)n*(n-1)/2;
		solve(it->second);
	}
}
int main()
{
	int N;cin>>N>>P;
	vector<int>A(N);
	for(int i=0;i<N;i++)cin>>A[i];
	solve(A);
	cout<<ans<<endl;
}
0