Submission #71162972
Source Code Expand
#include<bits/stdc++.h>
using namespace std;
#define fir first
#define sec second
typedef long long ll;
typedef double db;
typedef pair<int, int> pii;
inline int read()
{
int x=0,t=1;
char c=getchar();
while(c<'0' || c>'9')
{
if(c=='-')
t=-1;
c=getchar();
}
while(c>='0' && c<='9')
{
x=(x<<1)+(x<<3)+(c^48);
c=getchar();
}
return x*t;
}
inline void write(ll x)
{
if(x<0)
{
x=-x;
putchar('-');
}
if(x>=10) write(x/10);
putchar(x%10^48);
return ;
}
inline void write_L(ll x)
{
write(x);
putchar('\n');
}
const int N=2e5+10;
const int M=20;
int len[N];
ll pow10[M];
int get_len(int x)
{
int ans=0;
while(x)
{
ans++;
x/=10;
}
return ans;
}
int main ()
{
int n=read(),m=read();
vector<int> vec[M];
for(int i=1;i<=n;i++)
{
int x=read();
int t=get_len(x);
len[i]=t;
vec[t].push_back(x);
}
pow10[0]=1;
for(int i=1;i<=10;i++)
pow10[i]=pow10[i-1]*10ll%m;
ll ans=0;
for(int l=1;l<=10;l++)
{
ll mul=pow10[l]%m;
for(int k=1;k<=10;k++)
{
unordered_map<long long,int> cnt;
for(int i:vec[k])
{
ll r=i*1ll*mul%m;
cnt[r]++;
}
for(int i:vec[l])
{
ll t=(-i%m+m)%m;
if(cnt.count(t))
ans+=cnt[t];
}
}
}
write_L(ans);
return 0;
}
Submission Info
| Submission Time | |
|---|---|
| Task | D - 183183 |
| User | Wang_H_Y_ |
| Language | C++23 (GCC 15.2.0) |
| Score | 400 |
| Code Size | 1652 Byte |
| Status | AC |
| Exec Time | 348 ms |
| Memory | 13464 KiB |
Compile Error
./Main.cpp:44:4: warning: built-in function 'pow10' declared as non-function [-Wbuiltin-declaration-mismatch]
44 | ll pow10[M];
| ^~~~~
Judge Result
| Set Name | Sample | All | ||||
|---|---|---|---|---|---|---|
| Score / Max Score | 0 / 0 | 400 / 400 | ||||
| Status |
|
|
| 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 | 3424 KiB |
| 00_sample_01.txt | AC | 1 ms | 3540 KiB |
| 00_sample_02.txt | AC | 1 ms | 3608 KiB |
| 00_sample_03.txt | AC | 1 ms | 3536 KiB |
| 01_random_00.txt | AC | 1 ms | 3464 KiB |
| 01_random_01.txt | AC | 1 ms | 3456 KiB |
| 01_random_02.txt | AC | 1 ms | 3540 KiB |
| 01_random_03.txt | AC | 1 ms | 3536 KiB |
| 01_random_04.txt | AC | 31 ms | 4372 KiB |
| 01_random_05.txt | AC | 43 ms | 5280 KiB |
| 01_random_06.txt | AC | 26 ms | 3900 KiB |
| 01_random_07.txt | AC | 108 ms | 7040 KiB |
| 01_random_08.txt | AC | 32 ms | 4432 KiB |
| 01_random_09.txt | AC | 258 ms | 10240 KiB |
| 01_random_10.txt | AC | 36 ms | 4576 KiB |
| 01_random_11.txt | AC | 348 ms | 13464 KiB |
| 01_random_12.txt | AC | 37 ms | 4424 KiB |
| 01_random_13.txt | AC | 18 ms | 3808 KiB |
| 01_random_14.txt | AC | 38 ms | 3968 KiB |
| 01_random_15.txt | AC | 105 ms | 4744 KiB |
| 01_random_16.txt | AC | 34 ms | 3920 KiB |
| 01_random_17.txt | AC | 16 ms | 3852 KiB |
| 01_random_18.txt | AC | 59 ms | 4264 KiB |
| 01_random_19.txt | AC | 35 ms | 4424 KiB |
| 01_random_20.txt | AC | 8 ms | 3768 KiB |