Submission #638309

# Submission time Handle Problem Language Result Execution time Memory
638309 2022-09-05T09:04:12 Z iee Spiderman (COCI20_spiderman) C++17
70 / 70
92 ms 10868 KB
// iee
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdio>
#include <vector>
#include <set>
#include <map>

#define rep(i, a, b) for (auto i = (a); i <= (b); ++i)
#define per(i, a, b) for (auto i = (a); i >= (b); --i)
#define fi first
#define se second
using ll = long long;
using ull = unsigned long long;
using namespace std;
void work(int);

template <class T> void read(T &x) {
  x = 0; int f = 1, ch = getchar();
  while (!isdigit(ch)) { if (ch == '-') f = -1; ch = getchar(); }
  while (isdigit(ch)) x = x * 10 + (ch - '0'), ch = getchar();
  x *= f;
}

int main() {
  int TT = 1; // cin >> TT;
  rep(CAS, 1, TT)
    work(CAS);
  return 0;
}
const int N = 3e5 + 5, M = 1e6 + 5;
int n, k, a[N];
int cnt[M], ans[M];
void work(int CASE) {
  scanf("%d%d", &n, &k);
  rep(i, 1, n) scanf("%d", &a[i]), cnt[a[i]]++;
  rep(i, k + 1, M - 1)
    for (int j = k; j < M; j += i)
      ans[j] += cnt[i];
  rep(i, 1, n) printf("%d ", ans[a[i]] - (k == 0));
}

Compilation message

spiderman.cpp: In function 'void work(int)':
spiderman.cpp:36:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   36 |   scanf("%d%d", &n, &k);
      |   ~~~~~^~~~~~~~~~~~~~~~
spiderman.cpp:37:21: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   37 |   rep(i, 1, n) scanf("%d", &a[i]), cnt[a[i]]++;
      |                ~~~~~^~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 14 ms 6484 KB Output is correct
2 Correct 14 ms 5588 KB Output is correct
3 Correct 41 ms 7672 KB Output is correct
4 Correct 74 ms 9620 KB Output is correct
5 Correct 40 ms 9036 KB Output is correct
6 Correct 79 ms 10868 KB Output is correct
7 Correct 35 ms 9100 KB Output is correct
8 Correct 35 ms 9036 KB Output is correct
9 Correct 84 ms 10780 KB Output is correct
10 Correct 92 ms 10720 KB Output is correct