Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <math.h>
- using namespace std;
- int a;
- bool polowa = false;
- int licznik = 1;
- int main()
- {
- cin>>a;
- int pol = a/2;
- pol++;
- int ruchy = 0;
- int ruch = 1;
- for(int i = 1;i <= a; i+=ruchy){
- if(i>pol){
- polowa = true;
- }
- ruchy+= licznik;
- ruch++;
- if(polowa == true){
- licznik--;
- }
- else{
- licznik++;
- }
- }
- cout<<ruch;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement