Submission #71166682


Source Code Expand

#include <bits/stdc++.h>
using namespace std;
#define int unsigned long long

const int MAXN = 2e5+5;
unordered_map<int, int> cnt[12];
// cnt[i][j]代表 x*1ei模m为j的数的个数
int n, m, a[MAXN], len[MAXN];

int lenth(int x)
{
    int ans = 0;
    while (x)
    {
        x/=10;
        ans++;
    }
    return ans;
}


signed main()
{
    cin >> n >> m;
    for (int i=1; i<=n; i++) 
    {
        cin >> a[i];
        len[i] = lenth(a[i]);
        // cout << len[i] << " ";
        int t = a[i];
        for (int j=0; j<=10; j++)
        {
            int mo = t%m;
            cnt[j][mo]++;
            t*=10;
            // cout << j << " " << mo << endl;
        }
    }
    int ans = 0;
    for (int i=1; i<=n; i++)
    {
        // cout << i << " ";
        if (a[i]%m==0)
        {
            ans += cnt[len[i]][0];
            // cout << "*" << cnt[len[i]][0] << endl;
        }
        else
        {
            ans += cnt[len[i]][m-a[i]%m];
            // cout << "+" << len[i] << " " << m-a[i]%m << " " << cnt[len[i]][m-a[i]%m] << endl;
        }
    }
    cout << ans;

    return 0;
}

Submission Info

Submission Time
Task D - 183183
User nxzwcry
Language C++23 (GCC 15.2.0)
Score 400
Code Size 1162 Byte
Status AC
Exec Time 840 ms
Memory 116152 KiB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 400 / 400
Status
AC × 4
AC × 25
Set Name Test Cases
Sample 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt, 00_sample_03.txt
All 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt, 00_sample_03.txt, 01_random_00.txt, 01_random_01.txt, 01_random_02.txt, 01_random_03.txt, 01_random_04.txt, 01_random_05.txt, 01_random_06.txt, 01_random_07.txt, 01_random_08.txt, 01_random_09.txt, 01_random_10.txt, 01_random_11.txt, 01_random_12.txt, 01_random_13.txt, 01_random_14.txt, 01_random_15.txt, 01_random_16.txt, 01_random_17.txt, 01_random_18.txt, 01_random_19.txt, 01_random_20.txt
Case Name Status Exec Time Memory
00_sample_00.txt AC 1 ms 3432 KiB
00_sample_01.txt AC 1 ms 3536 KiB
00_sample_02.txt AC 1 ms 3488 KiB
00_sample_03.txt AC 1 ms 3600 KiB
01_random_00.txt AC 1 ms 3612 KiB
01_random_01.txt AC 1 ms 3552 KiB
01_random_02.txt AC 1 ms 3612 KiB
01_random_03.txt AC 1 ms 3560 KiB
01_random_04.txt AC 58 ms 6760 KiB
01_random_05.txt AC 111 ms 27756 KiB
01_random_06.txt AC 37 ms 5652 KiB
01_random_07.txt AC 263 ms 56792 KiB
01_random_08.txt AC 44 ms 6176 KiB
01_random_09.txt AC 639 ms 103080 KiB
01_random_10.txt AC 54 ms 6824 KiB
01_random_11.txt AC 840 ms 116152 KiB
01_random_12.txt AC 55 ms 6812 KiB
01_random_13.txt AC 32 ms 11412 KiB
01_random_14.txt AC 27 ms 5652 KiB
01_random_15.txt AC 257 ms 54412 KiB
01_random_16.txt AC 26 ms 5672 KiB
01_random_17.txt AC 27 ms 10680 KiB
01_random_18.txt AC 41 ms 6632 KiB
01_random_19.txt AC 54 ms 6816 KiB
01_random_20.txt AC 12 ms 4232 KiB