fork download
#include <iostream>
#define SIZE 1000001
using namespace std;
 
long long n, k, a, cnt[SIZE], i, j, x = 0;
int main() {
    cin >> n >> k;
    for (i = 0; i < n; ++i) {
        cin >> a;
        ++cnt[a];
    }
    for (i = k + 1; i < SIZE; ++i) {
        if (cnt[i] > 0) {
            for (j = k; j < SIZE; j += i)
                if (cnt[j] > 0) {
                    if (i == j) {
                    	x += cnt[i] * (cnt[i] - 1);
                    }
                    else {
                    	x += cnt[j] * cnt[i];
                    }
            }
        }
    }
    cout << x << endl;
}
Success #stdin #stdout 0s 23048KB
stdin
Standard input is empty
stdout
0