Submission #638258

# Submission time Handle Problem Language Result Execution time Memory
638258 2022-09-05T06:32:14 Z colazcy Spiderman (COCI20_spiderman) C++17
70 / 70
79 ms 10124 KB
#include <cstdio>
#include <cassert>
#include <algorithm>
#define let const auto
#define rep(name,beg,end) for(auto lim_##name = end,name = beg;name <= lim_##name;name++)
#define per(name,beg,end) for(auto lim_##name = end,name = beg;name >= lim_##name;name--)
#define repn(lim) for(auto REPN_lIM = lim,REPN = 1;REPN <= REPN_lIM;REPN++)
#define debug(...) fprintf(stderr,__VA_ARGS__)
#define trace() debug("line : %d, Function : %s\n",__LINE__,__FUNCTION__)
using ll = long long;
constexpr int maxn = 3e5 + 100,maxm = 1e6 + 100;

int n,k,val[maxn];
int f[maxm],ans[maxm];
int main(){
#ifndef ONLINE_JUDGE
    // std::freopen("fufu.in","r",stdin);
    // std::freopen("fufu.out","w",stdout);
#endif
    std::scanf("%d %d",&n,&k);
    rep(i,1,n)
        std::scanf("%d",val + i),
        f[val[i]]++;
    rep(i,k + 1,maxm - 1)
        if(f[i])
            for(int r = k;r < maxm;r += i)
                ans[r] += f[i];
    rep(i,1,n)
        if(val[i] < k)std::printf("%d ",0);
        else std::printf("%d ",ans[val[i]] - (k == 0));
    return 0;
}

Compilation message

spiderman.cpp: In function 'int main()':
spiderman.cpp:20:15: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   20 |     std::scanf("%d %d",&n,&k);
      |     ~~~~~~~~~~^~~~~~~~~~~~~~~
spiderman.cpp:22:19: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   22 |         std::scanf("%d",val + i),
      |         ~~~~~~~~~~^~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 6 ms 6524 KB Output is correct
2 Correct 8 ms 5588 KB Output is correct
3 Correct 30 ms 7236 KB Output is correct
4 Correct 67 ms 8568 KB Output is correct
5 Correct 35 ms 8716 KB Output is correct
6 Correct 79 ms 10124 KB Output is correct
7 Correct 36 ms 8712 KB Output is correct
8 Correct 34 ms 8672 KB Output is correct
9 Correct 77 ms 9920 KB Output is correct
10 Correct 72 ms 9940 KB Output is correct