fork download
  1. #include <iostream>
  2. using namespace std;
  3. bool yes(int a,int b){
  4. int su=0;
  5. for(int i=1;i<a;i++){
  6. if(a%i==0)su+=i;
  7. }
  8. if(su==b)return true;
  9. return false;
  10. }
  11. int main() {
  12. int n,c=0;
  13. cin>> n;
  14. int* a= new int[n*n];
  15. for(int i=0;i<n*n;i++){
  16. cin>>a[i];
  17. }
  18. for(int i=0;i<n*n;i++){
  19. for(int j=i+1;j<n*n;j++){
  20. if(yes(a[i],a[j]))c++;
  21. }
  22. }
  23. cout<<c;
  24. delete[] a;
  25. return 0;
  26. }
Success #stdin #stdout 0.01s 5324KB
stdin
3
284
1
2
3
220
6
7
8
9
stdout
1