답안 #485798

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
485798 2021-11-09T11:54:53 Z LptN21 Spiderman (COCI20_spiderman) C++14
14 / 70
96 ms 6384 KB
#include <bits/stdc++.h>
using namespace std;
#define fastIO ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL)
#define PI acos(-1.0)
#define FF first
#define SS second
#define eps 1e-3
// vector
#define pb push_back
#define sz(v) int((v).size())
#define all(v) (v).begin(), (v).end()
#define lb lower_bound
#define ub upper_bound
// bit
#define CNTBIT(x) __builtin_popcount(x)
#define ODDBIT(x) __builtin_parity(x)
#define MASK(i) (1ll<<(i))
#define BIT(x, i) (((x)>>(i))&1)
#define SUBSET(big, small) (((big)&(small))==(small))
#define MINBIT(x) (x)&(-x)
// typedef
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
//typedef __int128 i128;
typedef pair<int, int> ii;
typedef pair<int, ii> i3;
/* CODE BELOW */
const int N=3e5+7, M=1e6+7;
const int MOD=1e9+7;
const int oo=1e9+7;

int n, m, k, t;

int a[N], cnt[M];

signed main() {
    //freopen("test.inp", "r", stdin);
    //freopen("test.out", "w", stdout);
    //fastIO;
    scanf("%d%d", &n, &m);
    for(int i=1;i<=n;i++) {
        scanf("%d", &a[i]);
        cnt[a[i]]++;
    }

    for(int i=M-1;i>m;i--)
        for(int j=i*2;j<M;j+=i)
            cnt[j]+=cnt[i];

    for(int i=1;i<=n;i++) {
        if(a[i]<m) printf("0");
        else printf("%d ", cnt[a[i]-m]-(!m?1:0));
    }

    return 0;
}
/* stuff you should look for
    - int overflow, array bounds
    - special/edge cases (n=1?)
    - do smth instead of nothing and stay organized
    - WRITE STUFF DOWN
    - DONT JUST STICK ON ONE APPROACH
*/

Compilation message

spiderman.cpp: In function 'int main()':
spiderman.cpp:41:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   41 |     scanf("%d%d", &n, &m);
      |     ~~~~~^~~~~~~~~~~~~~~~
spiderman.cpp:43:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   43 |         scanf("%d", &a[i]);
      |         ~~~~~^~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 21 ms 4172 KB Output isn't correct
2 Incorrect 16 ms 4172 KB Output isn't correct
3 Incorrect 35 ms 4968 KB Output isn't correct
4 Incorrect 72 ms 6384 KB Output isn't correct
5 Correct 35 ms 4856 KB Output is correct
6 Correct 80 ms 6340 KB Output is correct
7 Incorrect 29 ms 4868 KB Output isn't correct
8 Incorrect 37 ms 4852 KB Output isn't correct
9 Incorrect 84 ms 6256 KB Output isn't correct
10 Incorrect 96 ms 6128 KB Output isn't correct