2 条题解

  • 1
    @ 2025-3-20 11:39:55

    首先翻译一下题面,对于每一个数输出序列中有几个它的倍数

    首先考虑离散化所有的数

    然后对于每一个数从 22 倍开始枚举,一直暴力枚举到最大值,然后记录答案

    时间复杂度玄学

    • 0
      @ 2025-7-7 9:21:22
      #include <iostream>
      using namespace std;
      
      const int N = 100010, M = 1000010;
      int n, mx, p[N], t[M], g[M];
      
      int main() {
      	ios::sync_with_stdio(false);
      	cin.tie(0), cout.tie(0);
      	cin >> n;
      	for (int i = 0; i < n; ++i) {
      		cin >> p[i];
      		mx = max(mx, p[i]);
      		t[p[i]]++;
      	}
      	for (int i = 1; i <= mx; ++i) {
      		if (!t[i]) continue;
      		for (int j = i; j <= mx; j += i) g[j] += t[i];
      	}
      	for (int i = 0; i < n; ++i) cout << g[p[i]] - 1 << "\n";
      	return 0;
      }
      
      • 1

      信息

      ID
      94
      时间
      1000ms
      内存
      256MiB
      难度
      6
      标签
      (无)
      递交数
      33
      已通过
      11
      上传者