Submission #71160286


Source Code Expand

#include<bits/stdc++.h>
typedef long long ll;
using namespace std;

ll f(ll x, ll y){
    ll ans = stoll(to_string(x) + to_string(y));
    return ans;
}

int main(){
    ll n,m;
    cin >> n >> m;
    ll A[n];
    for(int i = 0; i < n; i++) cin >> A[i];
    // for(int i = 0; i < n; i++) A[i] %= m;


    vector<ll> ten_pow(15);
    ten_pow[0] = 1;
    for(int i = 0; i < 14; i++) ten_pow[i+1] = (ten_pow[i] * 10) % m;

    ll ans = 0;
    // 桁数
    for(int digit = 1; digit <= 11; digit++){
        map<ll, ll> cnt;
        for(int i = 0; i < n; i++){
            cnt[(A[i] *  ten_pow[digit]) % m]++;
        }

        for(int i = 0; i < n; i++){
            if(to_string(A[i]).size() == digit){
                ans += cnt[(m - A[i] % m) % m]; 
            }
        }
        // cout << ans << endl;
    }
    cout << ans << endl;


    // for(int i = 0; i < n; i++){
    //     for(int j = 0; j < n; j++){
    //         ll val = f(A[i], A[j]);
    //         if(val % m == 0) cout << A[i] << " " << A[j] << endl;
    //     }
    // }
}

Submission Info

Submission Time
Task D - 183183
User sakimori_coder
Language C++23 (GCC 15.2.0)
Score 400
Code Size 1090 Byte
Status AC
Exec Time 1068 ms
Memory 31684 KiB

Compile Error

./Main.cpp: In function 'int main()':
./Main.cpp:31:39: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   31 |             if(to_string(A[i]).size() == digit){
      |                ~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~

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 10 ms 6456 KiB
00_sample_01.txt AC 2 ms 6428 KiB
00_sample_02.txt AC 2 ms 6428 KiB
00_sample_03.txt AC 2 ms 6268 KiB
01_random_00.txt AC 2 ms 6332 KiB
01_random_01.txt AC 2 ms 6372 KiB
01_random_02.txt AC 2 ms 6404 KiB
01_random_03.txt AC 2 ms 6400 KiB
01_random_04.txt AC 86 ms 7964 KiB
01_random_05.txt AC 143 ms 12048 KiB
01_random_06.txt AC 107 ms 7284 KiB
01_random_07.txt AC 380 ms 17860 KiB
01_random_08.txt AC 93 ms 7824 KiB
01_random_09.txt AC 931 ms 28868 KiB
01_random_10.txt AC 93 ms 7964 KiB
01_random_11.txt AC 1068 ms 31684 KiB
01_random_12.txt AC 138 ms 7964 KiB
01_random_13.txt AC 51 ms 7628 KiB
01_random_14.txt AC 98 ms 7284 KiB
01_random_15.txt AC 469 ms 14112 KiB
01_random_16.txt AC 81 ms 7480 KiB
01_random_17.txt AC 45 ms 7576 KiB
01_random_18.txt AC 139 ms 8080 KiB
01_random_19.txt AC 85 ms 7936 KiB
01_random_20.txt AC 19 ms 6800 KiB