Submission #231820

#TimeUsernameProblemLanguageResultExecution timeMemory
231820CodeTiger927Spiderman (COCI20_spiderman)C++14
70 / 70
1654 ms14936 KiB
using namespace std; #include <iostream> #include <unordered_map> #include <cmath> unordered_map<int,int> us; int zero = 0; int arr[300005]; int ans[300005]; int main() { int N,K; cin >> N >> K; for(int i = 0;i < N;i++) { int cur; cin >> cur; arr[i] = cur; us[cur]++; if(cur > K) { zero++; } } for(int i = 0;i < N;++i) { int cur = arr[i] - K; if(cur < 0) { continue; }else if(cur == 0) { ans[i] = zero; continue; } for(int j = 1;j <= sqrt(cur);++j) { if(cur % j == 0) { int counter = cur / j; if(j > K) { ans[i] += us[j]; } if(counter > K && counter != j) { ans[i] += us[counter]; } } } if(K == 0) { --ans[i]; } } for(int i = 0;i < N;i++) { cout << ans[i] << " "; } cout << endl; }
#Verdict Execution timeMemoryGrader output
Fetching results...