题目描述：

观察到a[i]与a[j]拼起来的结果即为 a [ i ] × 10 ⌊ l o g 10 a [ j ] ⌋ + a [ j ] a [ i ] × 10 ⌊ l o g 10 ⁡ a [ j ] ⌋ + a [ j ] a[i]×10⌊log10a[j]⌋+a[j]a[i]×10⌊log10⁡a[j]⌋+a[j]

#include<bits/stdc++.h>
#define x first
#define y second
#define mem-1(h) memset(h,-1,sizeof h)
#define mem0(h) memset(h,0,sizeof h)
#define mcp(a,b) memcpy(a,b,sizeof b)
using namespace std;
typedef long long LL;
typedef unsigned long long ull;
typedef pair<int,int>PII;
typedef pair<double,double>PDD;
namespace IO{

LL o=0,f=1;char c=getchar();
while(c<'0'||c>'9'){
if(c=='-')f=-1;c=getchar();}
while(c>='0'&&c<='9'){
o=o*10+c-'0';c=getchar();}
return o*f;
}
}using namespace IO;
//#############以上是自定义技巧（可忽略）##########
const int N=1e5+7,M=2e5+7,INF=0x3f3f3f3f,mod=1e8+7,P=131;
LL ans;
int a[N];
int cnt[12][N];
int n,k;
int log_10(int x){

int res=0;
while(x){

x/=10;
res++;
}
return res;
}
void solve(){

for(int i=0;i<n;i++){

ans+=cnt[log_10(a[i])][(k-a[i]%k)%k];
for(int j=0,pow=1;j<11;j++){

cnt[j][pow*1ll*a[i]%k]++;
pow=pow*10%k;
}
}
}
int main(){

cin>>n>>k;
for(int i=0;i<n;i++)cin>>a[i];
solve();
mem0(cnt);
reverse(a,a+n);
solve();
cout<<ans<<endl;
return 0;
}