結果

問題 No.2260 Adic Sum
ユーザー lddlinanlddlinan
提出日時 2023-04-07 22:03:23
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 728 ms / 2,000 ms
コード長 899 bytes
コンパイル時間 1,079 ms
コンパイル使用メモリ 91,672 KB
実行使用メモリ 8,960 KB
最終ジャッジ日時 2024-04-15 23:54:11
合計ジャッジ時間 5,763 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
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 2 ms
5,376 KB
testcase_09 AC 2 ms
5,376 KB
testcase_10 AC 2 ms
5,376 KB
testcase_11 AC 2 ms
5,376 KB
testcase_12 AC 3 ms
5,376 KB
testcase_13 AC 3 ms
5,376 KB
testcase_14 AC 21 ms
5,888 KB
testcase_15 AC 32 ms
6,528 KB
testcase_16 AC 17 ms
5,504 KB
testcase_17 AC 35 ms
6,784 KB
testcase_18 AC 410 ms
8,448 KB
testcase_19 AC 429 ms
8,576 KB
testcase_20 AC 284 ms
8,576 KB
testcase_21 AC 295 ms
8,576 KB
testcase_22 AC 245 ms
8,704 KB
testcase_23 AC 168 ms
8,832 KB
testcase_24 AC 425 ms
8,960 KB
testcase_25 AC 55 ms
8,320 KB
testcase_26 AC 53 ms
8,320 KB
testcase_27 AC 57 ms
8,448 KB
testcase_28 AC 53 ms
8,576 KB
testcase_29 AC 54 ms
8,320 KB
testcase_30 AC 53 ms
6,656 KB
testcase_31 AC 112 ms
7,296 KB
testcase_32 AC 114 ms
7,168 KB
testcase_33 AC 49 ms
8,704 KB
testcase_34 AC 79 ms
8,960 KB
testcase_35 AC 728 ms
8,704 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function 'int main()':
main.cpp:40:14: warning: 'r' may be used uninitialized [-Wmaybe-uninitialized]
   40 |             r+=t;
      |             ~^~~
main.cpp:30:11: note: 'r' was declared here
   30 |     LL b, r, t;
      |           ^

ソースコード

diff #

#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include <map>
#include <vector>
#include <queue>
#include <deque>
#include <set>
#include <stack>
#include <algorithm>
#include <array>
#include <unordered_set>
#include <unordered_map>
#include <string>
using namespace std;

bool rcmp(int a, int b) { return a>b; }
typedef long long LL;
class mypcmp {
public:
    bool operator()(const int& a, const int& b) {
        return a<b;
    }
};


int as[100004];
int main() {
    int n, i, p, mv, c;
    LL b, r, t;
    scanf("%d %d", &n, &p);
    for (i=0; i<n; i++) scanf("%d", &as[i]);
    mv=as[0]; for (i=1; i<n; i++) mv=max(mv, as[i]);
    for (b=p; b<=mv; b*=p) {
        map<int, int> cs;
        for (i=0; i<n; i++) cs[as[i]%b]++;
        for (auto x: cs) {
            c=x.second;
            t=c; t*=c-1; t/=2;
            r+=t;
        }
    }
    printf("%lld\n", r);
    return 0;
}
0