# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
735205 | DangerNoodle7591 | Spiderman (COCI20_spiderman) | C++17 | 1187 ms | 6432 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define ll long long
#define lalala ios_base::sync_with_stdio(false);cin.tie(NULL);
//#define mod 1000000007
#define N 1000005
//#define big 1000000000000000007
int mp[N];
int main(){
lalala;
int n,k;cin>>n>>k;
int cnt=0;
int arr[n];
for(int i=0;i<n;i++){
cin>>arr[i];
mp[arr[i]]++;
if(arr[i]>k)cnt++;
}
for(int i=0;i<n;i++){
if(arr[i]<k){cout<<"0 ";continue;}
if(arr[i]==k){cout<<cnt<<" ";continue;}
int uwu=arr[i]-k, cev=0;
//cout<<arr[i]<<" "<<uwu<<endl;
for(int j=1;j<=sqrt(uwu);j++){
if(uwu%j)continue;
//cout<<cev<<" "<<j<<" "<<uwu/j<<" "<<mp[j]<<" "<<mp[uwu/j]<<endl;
if(arr[i]%j==k){
cev+=mp[j];
}
if(j*j!=uwu && arr[i]%(uwu/j)==k)cev+=mp[uwu/j];
}
if(k==0)cev--;
cout<<cev<<" ";
}
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |