fork download
  1. /*
  2. //to enter the link remove the space after https:
  3. link of problem: https: //codeforces.com/gym/103373/problem/B
  4. TOPIC : https: //youkn0wwho.academy/topic-list/harmonic_series
  5. */
  6. #include<bits/stdc++.h>
  7. using namespace std;
  8. #define int long long
  9. signed main(){
  10.  
  11. const int N = 1e6;
  12.  
  13. vector<int>pre(N+1,0);
  14.  
  15. for(int i=1;i<=N;i++){
  16. for(int j=i*2;j<=N;j+=i){
  17. //we skipped i because we can't count when i==j
  18. pre[j]+=i;
  19. }
  20. }
  21.  
  22. //
  23.  
  24. int n; cin>>n;
  25.  
  26. for(int i=1 ,x ;i<=n;i++){
  27. cin>>x;
  28. cout<<(pre[x]==x?"perfect":(pre[x]<x?"deficient":"abundant"))<<'\n';
  29. }
  30.  
  31.  
  32. }
Success #stdin #stdout 0.05s 10856KB
stdin
3
12 21 28
stdout
abundant
deficient
perfect