Submission #736512

# Submission time Handle Problem Language Result Execution time Memory
736512 2023-05-05T20:27:36 Z vjudge1 Spiderman (COCI20_spiderman) C++14
70 / 70
1145 ms 8212 KB
#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
1 Correct 7 ms 2648 KB Output is correct
2 Correct 7 ms 1756 KB Output is correct
3 Correct 286 ms 3904 KB Output is correct
4 Correct 836 ms 6444 KB Output is correct
5 Correct 338 ms 5452 KB Output is correct
6 Correct 980 ms 8172 KB Output is correct
7 Correct 378 ms 5456 KB Output is correct
8 Correct 392 ms 5452 KB Output is correct
9 Correct 1145 ms 8212 KB Output is correct
10 Correct 1108 ms 8128 KB Output is correct