# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
249691 | dvdg6566 | Spiderman (COCI20_spiderman) | C++14 | 1769 ms | 128120 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<pi> vpi;
typedef long double ld;
#define pb emplace_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define ALL(x) x.begin(), x.end()
#define SZ(x) (ll)x.size()
#define f first
#define s second
const ll MAXN=300001;
const ll MAXK=1000001;
const ll INF = 1e9;
const ll MOD = 1e9+7;
int A[MAXN];
int B[MAXK];
int res[MAXN];
int dp[MAXK];
int N,K,a;
vi V[MAXK];
int calc(int x){
if(dp[x]!=-1)return dp[x];
dp[x]=0;
for(auto i:V[x])dp[x]+=B[i];
if(K==0)--dp[x];
return dp[x];
}
int main(){
for(int i=1;i<=MAXK;++i)for(int j=i;j<=MAXK;j+=i){
V[j].pb(i);
}
cin>>N>>K;
memset(res,-1,sizeof(res));
memset(dp,-1,sizeof(dp));
int x=0;
for(int i=1;i<=N;++i){
cin>>A[i];
if(A[i]<K)res[i]=0;
if (A[i]>K){
++x;
B[A[i]]++;
}
}
for(int i=1;i<=N;++i)if(A[i]==K){
res[i]=x;
}
for(int i=1;i<=N;++i)if(res[i]==-1){
res[i]=calc(A[i]-K);
}
for(int i=1;i<=N;++i)cout<<res[i]<<' ';
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |