Advertisement
a53

extindere

a53
Jan 13th, 2018
147
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.62 KB | None | 0 0
  1. # include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. ifstream f("extindere.in");
  5. ofstream g("extindere.out");
  6.  
  7. int n;
  8.  
  9. int main()
  10. {
  11. f >> n;
  12.  
  13. int p = 1;
  14. while( p * 4 < n )
  15. p *= 4;
  16.  
  17. bool op = 0; /// codific, pentru usurinta cu {0,1}, nu cu {1,2}
  18. while( n > 4){
  19. if( n > p && n <= 3*p ) op ^= 1;
  20. n = (n-1) % p + 1;
  21. p /= 4;
  22. }
  23.  
  24.  
  25. if( op ){
  26. if ( n == 2 || n == 3 ) g << "1\n";
  27. if ( n == 1 || n == 4 ) g << "2\n";
  28. }
  29. else{
  30. if ( n == 2 || n == 3 ) g << "2\n";
  31. if ( n == 1 || n == 4 ) g << "1\n";
  32. }
  33.  
  34. return 0;
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement