怎么想都是对的,就 AC 了 2 个点
查看原帖
怎么想都是对的,就 AC 了 2 个点
814343
bc2_cryeggy楼主2023/12/13 16:43

不知道为什么。

#include <iostream>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <vector>

using namespace std;

using ll = long long;

const int kMaxN = 1e6 + 10, kInf = (((1 << 30) - 1) << 1) + 1;
const ll kLInf = 9.22e18;

int n, m, a[kMaxN], b[kMaxN], ans = 0;
 
int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cin >> n >> m;
  for (int i = 1; i <= n; ++ i) {
    cin >> a[i];
  }
  for (int i = 1; i <= m; ++ i) {
    cin >> b[i];
  }
  for (int i = 1; i <= n; ++ i) {
    if (!a[i]) {
      continue;
    }
    for (int j = a[i]; j <= m; j += a[i]) {
      if (!b[j]) {
        continue;
      }
      if (i / b[j] == j / a[i] && i % b[j] == 0 && j % a[i] == 0) {
        ++ ans;
      }
    }
  }
  cout << ans << '\n';
  return 0;
}
2023/12/13 16:43
加载中...