Saleh127

cf 1076B

Jul 17th, 2020
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.83 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. #define test int t; cin>>t; while (t--)
  4. #define ll long long int
  5. #define fellow_junior ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
  6. int main()
  7. {
  8. fellow_junior
  9. ll a,c=0,d,e,f,i,j,k,l;
  10. cin>>a;
  11. while(1)
  12. {
  13. if(a==0)
  14. {
  15. cout<<c<<endl;
  16. return 0;
  17. }
  18. if(a%2==0)
  19. {
  20. c+=a/2;
  21. a=a-a;
  22. }
  23. else
  24. {
  25. d=0;
  26. for(i=3;i<=sqrt(a);i+=2)
  27. {
  28. if(a%i==0)
  29. {
  30. d=1;
  31. a=a-i;
  32. c++;
  33. break;
  34. }
  35. }
  36. if(d==0)
  37. {
  38. a=a-a;
  39. c++;
  40. }
  41. }
  42. }
  43. return 0;
  44. }
Advertisement
Add Comment
Please, Sign In to add comment