# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
644928 | 1zaid1 | Spiderman (COCI20_spiderman) | C++17 | 541 ms | 19180 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define endl '\n';
const int M = 2e6+5, MOD = 1e9+7;
int fr[M], ans[M];
signed main() {
cin.tie(0)->sync_with_stdio(0);
int n, k;
cin >> n >> k;
vector<int> v(n);
for (int&i:v) cin >> i;
for (int i:v) fr[i]++;
for (int&i:v) i -= k;
for (int i:v) {
if (i < 0) continue;
if (ans[i]) continue; fr[i+k]--;
for (int x = 1; x*x <= i; x++) {
if (i%x == 0) {
if ((i+k)%x == k) ans[i] += fr[x];
if (x*x != i) if ((i+k)%(i/x) == k) ans[i] += fr[i/x];
}
} fr[i+k]++;
}
for (int i:v) ans[0] += i > 0;
for (int i:v) {
if (i >= 0) cout << ans[i] << ' ';
else cout << 0 << ' ';
} cout << endl;
return 0;
}
/*
a%b = k
6 3
4 3 12 6 8 2
0 1 2 3 4 5 6 7 8 9 10 11 12
fr:1 1 0 1 0 0 0 0 0 1 0 0 0
as:0 0 0 0 0 0 0 0 0 0 0 0 0
*/
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |