Advertisement
Guest User

Untitled

a guest
Mar 22nd, 2018
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.50 KB | None | 0 0
  1. #include <iostream>
  2. #include <math.h>
  3. using namespace std;
  4.  
  5. int a;
  6. bool polowa = false;
  7. int licznik = 1;
  8.  
  9. int main()
  10. {
  11.  
  12. cin>>a;
  13. int pol = a/2;
  14. pol++;
  15. int ruchy = 0;
  16. int ruch = 1;
  17. for(int i = 1;i <= a; i+=ruchy){
  18.  
  19. if(i>pol){
  20. polowa = true;
  21. }
  22.  
  23. ruchy+= licznik;
  24. ruch++;
  25.  
  26. if(polowa == true){
  27. licznik--;
  28. }
  29.  
  30. else{
  31. licznik++;
  32. }
  33.  
  34.  
  35.  
  36. }
  37.  
  38. cout<<ruch;
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement