整数拼接
using namespace std;
const int N = 1e5 + 10;
typedef long long LL;
int a[N];
LL s[11][N];
int main()
{
LL n, k;
cin >> n >>k;
for(int i = 1; i <= n; i ++)
{
cin >> a[i];
LL t = 1;
for(int j = 0;j < 11; j ++)
{
s[j][t % k * a[i] % k] ++;
t = t * 10 ;
}
}
LL res = 0;
for(int i = 1; i <= n; i ++)
{
LL t = (- a[i] % k + k) % k;
int len = to_string(a[i]).size();
res += s[len][t];
LL r = t;
while(len --)r = r * 10 ;// 判断是不是有相同数拼在一起的情况
r %= k;
if(r == (k - t) % k){
res --;
}
}
cout << res <<endl;
}