nicuvlad76

Untitled

Jan 12th, 2021
152
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.88 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. int main()
  5. {
  6. int n,d,a,b,k;
  7. bool prim;
  8. bool aprim=0;
  9. cin>>n;
  10. d=2;
  11. while(aprim==0 && d*d<n)
  12. {
  13. if(n%d==0)
  14. {
  15. a=d;
  16. b=n/d;
  17. ///a este prim
  18. prim=1;
  19. if(a<2)prim=0;
  20. else if(a%2==0 && a!=2)prim=0;
  21. else for(k=3; k*k<=a; k+=2)
  22. if(a%k==0)prim=0;
  23. if(prim)
  24. {
  25. ///b este prim
  26. prim=1;
  27. if(b<2)prim=0;
  28. else if(b%2==0 && b!=2)prim=0;
  29. else for(k=3; k*k<=b; k+=2)
  30. if(b%k==0)prim=0;
  31. if(prim==1)aprim=1;
  32. }
  33. }
  34. if(d==2)d++;
  35. else d+=2;
  36. }
  37.  
  38. if(aprim==1)cout<<"DA";
  39. else cout<<"NU";
  40. return 0;
  41. }
  42.  
  43.  
Advertisement
Add Comment
Please, Sign In to add comment