二、阅读程序1

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#include <bits/stdc++.h> 
long long n, m, t, a[1000005];  
using namespace std; 
int main() { 
	cin >> n >> m;  
	while (m > 0) { 
	    t++;  
	    m--;    
	    if (m <= 0)  
	        break;  
	    a[t] = a[t - 1] + 1;   
	    while (m > (1 << n - a[t]) && a[t] <= n) { 
	        m -= 1 << n - a[t]; 
	        a[t]++;  
	    }  
	}  
	if (t != 1)  
	    for (int i = 1; i < t; i++)  
	        cout << a[i] << " "; 
	else  
	    puts("0"); 
	return 0; 
	} 
Scroll to Top