Submission #339954

#TimeUsernameProblemLanguageResultExecution timeMemory
339954HazemSpiderman (COCI20_spiderman)C++14
70 / 70
1865 ms126832 KiB
/* ID: tmhazem1 LANG: C++14 TASK: pprime */ #include <bits/stdc++.h> using namespace std; #define S second #define F first #define LL long long const int N = 1e6 + 10; LL LINF = 100000000000000000; LL INF = 1000000000; vector<int>vec[N]; int freq[N],a[N],pr[N]; int main() { //freopen("out.txt","w",stdout); int n,k,mx = 0; scanf("%d%d",&n,&k); for(int i=1;i<=n;i++) scanf("%d",&a[i]),mx = max(mx,a[i]),freq[a[i]]++; for(int i=1;i<=mx;i++){ pr[i] = pr[i-1]+freq[i]; for(int j=i;j<=mx;j+=i) vec[j].push_back(i); } for(int i=1;i<=n;i++){ int ans = a[i]==k?n-pr[a[i]]:0; if(a[i]>k) for(auto x:vec[a[i]-k]) ans += freq[x]*(a[i]%x==k); printf("%d ",ans-(!k)); } puts(""); }

Compilation message (stderr)

spiderman.cpp: In function 'int main()':
spiderman.cpp:26:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   26 |     scanf("%d%d",&n,&k);
      |     ~~~~~^~~~~~~~~~~~~~
spiderman.cpp:29:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   29 |         scanf("%d",&a[i]),mx = max(mx,a[i]),freq[a[i]]++;
      |         ~~~~~^~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...