Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- #include <vector>
- using namespace std;
- vector<int>nums;
- int sqrt(int a){
- int b = 1;
- for(int i=0;i<a/2;++i){
- b = b *2;
- if(b == a){
- return i+1;
- }
- }
- return 0 ;
- }
- int main(){
- int a,b,c=0;
- cin>>a;
- for(int i = 1; i < a+1; ++i){
- nums.push_back(i);
- }
- vector<int>A(a,0);
- b = a-1;
- for(int i = 2; i<a+1; i = i *2){
- if(a == i){
- for(int g = c; g < a; g=g+2){
- A[g]=nums[b];
- b-=1;
- }
- c+=1;
- }
- else{
- for(int g = c; g < a/i+1; g=g+(a/i)){
- A[g]=nums[b];
- b-=1;
- }
- c+=1;
- }
- }
- for(int i = 0; i < a; ++i){
- cout<<A[i]<<" ";
- }
- cout<<endl;
- return 0 ;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement