fork download
  1. #include <iostream>
  2. #define SIZE 1000001
  3. using namespace std;
  4.  
  5. long long n, k, a, cnt[SIZE], i, j, x = 0;
  6. int main() {
  7. cin >> n >> k;
  8. for (i = 0; i < n; ++i) {
  9. cin >> a;
  10. ++cnt[a];
  11. }
  12. for (i = k + 1; i < SIZE; ++i) {
  13. if (cnt[i] > 0) {
  14. for (j = k; j < SIZE; j += i)
  15. if (cnt[j] > 0) {
  16. if (i == j) {
  17. x += cnt[i] * (cnt[i] - 1);
  18. }
  19. else {
  20. x += cnt[j] * cnt[i];
  21. }
  22. }
  23. }
  24. }
  25. cout << x << endl;
  26. }
Success #stdin #stdout 0s 23048KB
stdin
Standard input is empty
stdout
0