제출 #890252

#제출 시각아이디문제언어결과실행 시간메모리
890252HADI_TSpiderman (COCI20_spiderman)C++14
0 / 70
1043 ms15696 KiB
#include<bits/stdc++.h> #define int long long #define pb(x) push_back(x) #define in(x) insert(x) #define F first #define S second #define endl '\n' #define yes cout<<"YES"<<endl; #define no cout<<"NO"<<endl; const int M=1e9+7; const int N=1e6+10; using namespace std; int freq[N]; int32_t main() { ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0); int n,c; cin>>n>>c; int a[n+10] , ans[n+10]={0}; for(int i=1;i<=n;i++){ cin>>a[i]; freq[a[i]]++; } for(int i=1;i<=n;i++) { int cur = a[i] - c; for(int j=1;j*j<=cur;j++) { if(cur % j == 0) { int f = j , s = cur/j; if(cur + f > a[i]) ans[i] += freq[f]; if(cur + s > a[i]){ if(f != s) ans[i] += freq[s]; } } } } sort(a+1,a+1+n); int idx = n; for(int i=n;i>=1;i--) { if(a[i] == c) { idx = i; break; } } for(int i=1;i<=n;i++){ if(a[i] == c) ans[i] += n-idx; cout<<ans[i]<<' '; } }
#Verdict Execution timeMemoryGrader output
Fetching results...