# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
471322 | HossamHero7 | Spiderman (COCI20_spiderman) | C++14 | 2092 ms | 10356 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define endl '\n'
void solve(){
int n,k;
cin>>n>>k;
vector <int> v(n);
for(auto &i:v) cin>>i;
if(k == 0){
map <int,int> mp;
for(auto i : v) mp[i] ++;
int cnt=0;
vector <int> ans(n);
for(auto i : v){
for(int j=1;j*j<=i;j++){
if(i == j){
ans[cnt] += mp[i]-1;
if(i == 1){
ans[cnt] += mp[i]-1;
}
else ans[cnt] += mp[1];
}
else {
if(i % j == 0){
ans[cnt] += mp[j];
if(j == (i/j)) continue;
if(i == (i/j)){
ans[cnt] += mp[i]-1;
}
else {
if(i % (i/j) == 0) ans[cnt] += mp[i/j];
}
}
}
}
cnt ++;
}
for(auto i : ans){
cout<<i<<" ";
}
cout<<endl;
}
else {
set <int> s;
map <int,int> mp;
for(auto i : v){
mp[i] ++;
s.insert(i);
}
map <int,int> ans;
for(auto i : s){
for(auto j : s){
if(i != j){
if(i%j == k) ans[i] += mp[j];
}
else {
if(i%j == k) ans[i] += mp[j]-1;
}
}
}
for(auto i : v) cout<<ans[i]<<" ";
cout<<endl;
}
}
int main()
{
ios_base::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
int t=1;
while(t--){
solve();
}
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |