Advertisement
a53

beta

a53
Jan 31st, 2020
431
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.37 KB | None | 0 0
  1. #include <fstream>
  2. using namespace std;
  3.  
  4. int main()
  5. {
  6. int n,poz;
  7. ifstream f("beta.in");
  8. f>>n>>poz;
  9. ofstream g("beta.out");
  10. if(poz>=2*n)
  11. {
  12. g<<-1;
  13. return 0;
  14. }
  15. int dir=0,len=n;
  16. while(poz>len)
  17. poz-=len,dir=1-dir,len/=2;
  18. if(dir==0)
  19. g<<n-len+poz;
  20. else
  21. g<<n-poz+1;
  22. return 0;
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement