답안 #644823

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
644823 2022-09-25T10:02:40 Z 1zaid1 Spiderman (COCI20_spiderman) C++17
21 / 70
1115 ms 20768 KB
#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;}
        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/x+k)%(i/x)==k) ans[i] += fr[i/x];
            }
        }
    }

    int x = 0;
    for (int i:v) x += i > 0;
    ans[0] = x;

    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
*/

Compilation message

spiderman.cpp: In function 'int main()':
spiderman.cpp:34:5: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   34 |     for (int i:v) if (i >= 0) {cout << ans[i] << ' ';} else cout << 0 << ' '; cout << endl;
      |     ^~~
spiderman.cpp:34:79: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   34 |     for (int i:v) if (i >= 0) {cout << ans[i] << ' ';} else cout << 0 << ' '; cout << endl;
      |                                                                               ^~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 9 ms 6360 KB Output is correct
2 Incorrect 8 ms 3796 KB Output isn't correct
3 Incorrect 292 ms 8388 KB Output isn't correct
4 Incorrect 840 ms 11608 KB Output isn't correct
5 Incorrect 337 ms 17544 KB Output isn't correct
6 Incorrect 974 ms 20768 KB Output isn't correct
7 Correct 385 ms 17612 KB Output is correct
8 Correct 381 ms 17548 KB Output is correct
9 Incorrect 1115 ms 20604 KB Output isn't correct
10 Incorrect 1101 ms 20468 KB Output isn't correct