Lucian_Adrian

#1574 Prietene

Nov 2nd, 2021
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.28 KB | None | 0 0
  1. #include<iostream>
  2. using namespace std;
  3.  
  4. int main()
  5. {
  6. int a,sa,b,sb,d;
  7.  
  8. cin>>a;
  9. cin>>b;
  10. sa=1;
  11. for(d=2;d<=a/2;d++)
  12. if(a%d==0)
  13. sa=sa+d;
  14.  
  15. if(sa==b)
  16. {
  17. sb=1;
  18. for(d=2;d<=b/2;d++)
  19. if(b%d==0)
  20. sb=sb+d;
  21.  
  22. if(sb==a)
  23. cout<<"PRIETENE";
  24. }
  25. else
  26. cout<<"NU SUNT PRIETENE";
  27. }
Advertisement
Add Comment
Please, Sign In to add comment