結果
| 問題 |
No.2260 Adic Sum
|
| コンテスト | |
| ユーザー |
tnakao0123
|
| 提出日時 | 2023-05-18 19:12:36 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 321 ms / 2,000 ms |
| コード長 | 811 bytes |
| コンパイル時間 | 616 ms |
| コンパイル使用メモリ | 63,844 KB |
| 実行使用メモリ | 13,444 KB |
| 最終ジャッジ日時 | 2024-12-16 08:27:47 |
| 合計ジャッジ時間 | 4,989 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 33 |
コンパイルメッセージ
main.cpp: In function 'int main()':
main.cpp:47:15: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17' [-Wc++17-extensions]
47 | for (auto [ai, ci]: acs) {
| ^
ソースコード
/* -*- coding: utf-8 -*-
*
* 2260.cc: No.2260 Adic Sum - yukicoder
*/
#include<cstdio>
#include<unordered_map>
#include<algorithm>
using namespace std;
/* constant */
const int MAX_N = 100000;
/* typedef */
typedef long long ll;
typedef unordered_map<int,int> umii;
/* global variables */
int as[MAX_N];
umii acs;
/* subroutines */
/* main */
int main() {
int n, p;
scanf("%d%d", &n, &p);
int maxa = 0;
for (int i = 0; i < n; i++) {
scanf("%d", as + i);
maxa = max(maxa, as[i]);
acs[as[i]]++;
}
int ep = 1;
while ((ll)ep * p <= maxa) ep *= p;
ll sum = 0;
while (ep > 0) {
umii bcs;
for (auto [ai, ci]: acs) {
sum += (ll)ci * (ci - 1) / 2;
bcs[ai % ep] += ci;
}
swap(acs, bcs);
ep /= p;
}
printf("%lld\n", sum);
return 0;
}
tnakao0123