#include<bits/stdc++.h>
using namespace std;
int main(){
long long a,b,c,d,e,p,h;
map <long long, long long> mp;
vector <long long> arr;
cin>>a>>c;
p=a;
h=0;
while(a--){
cin>>b;
mp[b]++;
arr.push_back(b);
if(b > c){
h++;
}
}
for(long long i=0;p>i;i++){
if(arr[i] <= c){
if(arr[i] == c){
e=h;
}
else{
e=0;
}
}
else{
e=0;
d=arr[i];
d-=c;
long long bol[d];
memset(bol,0,sizeof(bol));
if(mp[1] != 0 && (arr[i] % (1) == c)){
e+=mp[1];
bol[1]=1;
}
if(mp[d] != 0 && (arr[i] % (d) == c)){
e+=mp[d];
bol[d]=1;
}
long long j=2;
while(d != 1){
if(d % j == 0){
d/=j;
if(mp[d] != 0 && (arr[i] % (d) == c)){
if(bol[d] == 0){
e+=mp[d];
bol[d] = 1;
}
}
if(mp[arr[i] / d] != 0 && (arr[i] % ((arr[i] / d)) == c)){
if(bol[arr[i] / d] == 0){
e+=mp[arr[i] / d];
bol[arr[i] / d] = 1;
}
}
}
else{
j++;
}
}}
cout<<e<<" ";
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
20 ms |
15704 KB |
Execution killed with signal 11 |
2 |
Runtime error |
21 ms |
15120 KB |
Execution killed with signal 11 |
3 |
Runtime error |
61 ms |
18116 KB |
Execution killed with signal 11 |
4 |
Runtime error |
85 ms |
20968 KB |
Execution killed with signal 11 |
5 |
Runtime error |
51 ms |
15816 KB |
Execution killed with signal 11 |
6 |
Runtime error |
136 ms |
28724 KB |
Execution killed with signal 11 |
7 |
Runtime error |
59 ms |
15040 KB |
Execution killed with signal 11 |
8 |
Runtime error |
61 ms |
29432 KB |
Execution killed with signal 11 |
9 |
Runtime error |
145 ms |
33716 KB |
Execution killed with signal 11 |
10 |
Runtime error |
145 ms |
32936 KB |
Execution killed with signal 11 |