Advertisement
MatveyL

hgfdz

Jan 2nd, 2017
125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.88 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3. #include <vector>
  4. using namespace std;
  5. vector<int>nums;
  6.  
  7. int sqrt(int a){
  8. int b = 1;
  9. for(int i=0;i<a/2;++i){
  10. b = b *2;
  11. if(b == a){
  12. return i+1;
  13. }
  14. }
  15. return 0 ;
  16. }
  17.  
  18. int main(){
  19. int a,b,c=0;
  20. cin>>a;
  21. for(int i = 1; i < a+1; ++i){
  22. nums.push_back(i);
  23. }
  24. vector<int>A(a,0);
  25. b = a-1;
  26. for(int i = 2; i<a+1; i = i *2){
  27. if(a == i){
  28. for(int g = c; g < a; g=g+2){
  29. A[g]=nums[b];
  30. b-=1;
  31. }
  32. c+=1;
  33. }
  34. else{
  35. for(int g = c; g < a/i+1; g=g+(a/i)){
  36. A[g]=nums[b];
  37. b-=1;
  38. }
  39. c+=1;
  40. }
  41. }
  42.  
  43.  
  44. for(int i = 0; i < a; ++i){
  45. cout<<A[i]<<" ";
  46. }
  47. cout<<endl;
  48. return 0 ;
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement