Submission #334022

#TimeUsernameProblemLanguageResultExecution timeMemory
334022ronnithSpiderman (COCI20_spiderman)C++14
21 / 70
1286 ms8428 KiB
#include <bits/stdc++.h> typedef long long ll; #define mk make_pair #define f first #define s second using namespace std; int main(){ int n, k; scanf("%d%d", &n,&k); int h[n]; int mx = 0; for(int i = 0;i < n;i ++){ scanf("%d", &h[i]); mx = max(mx, h[i]); } int fr[mx + 1]; fill(fr, fr + mx + 1, 0); int cnt = 0; for(int i = 0;i < n;i ++){ if(h[i] > k){ fr[h[i]] ++; cnt ++; } } for(int i = 0;i < n;i ++){ int fac = h[i] - k; if(fac == 0){ printf("%d ", cnt); } else { int ans = 0; for(int j = 1;j * j <= fac;j ++){ if(fac % j == 0){ ans += fr[j]; if(j * j != fac)ans += fr[fac / j]; } } if(fac % h[i] == 0)ans --; printf("%d ", ans); } } puts(""); return 0; }

Compilation message (stderr)

spiderman.cpp: In function 'int main()':
spiderman.cpp:12:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   12 |  scanf("%d%d", &n,&k);
      |  ~~~~~^~~~~~~~~~~~~~~
spiderman.cpp:16:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   16 |   scanf("%d", &h[i]);
      |   ~~~~~^~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...