Submission #844584

# Submission time Handle Problem Language Result Execution time Memory
844584 2023-09-05T14:20:32 Z vjudge1 Spiderman (COCI20_spiderman) C++
70 / 70
1039 ms 10452 KB
#include<bits/stdc++.h>
using namespace std;
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	long long a,b,c,d,e,p,h;
	int mp[1000005];
	memset(mp,0,sizeof(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;
				for(long long j=1; d >= (j*j);j++){
					if(d % j == 0 ){
						if(arr[i] % j == c){
							e+=mp[j];
						}
						if(arr[i] % (d / j) == c){
							e+=mp[d / j];
						}
						if(j*j == d && (arr[i] % j == c) && arr[i] % (d / j) == c){
							e-=mp[j];
						}
					}
					
				}
				if(c == 0){
					e-=1;
				}
			}

		cout<<e<<" ";
	}


	
}
# Verdict Execution time Memory Grader output
1 Correct 8 ms 4184 KB Output is correct
2 Correct 8 ms 4188 KB Output is correct
3 Correct 277 ms 5596 KB Output is correct
4 Correct 790 ms 10452 KB Output is correct
5 Correct 313 ms 5336 KB Output is correct
6 Correct 905 ms 8892 KB Output is correct
7 Correct 352 ms 5340 KB Output is correct
8 Correct 352 ms 5344 KB Output is correct
9 Correct 1039 ms 9984 KB Output is correct
10 Correct 1034 ms 10196 KB Output is correct