1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#include <iostream>                                                             
using namespace std;                                                            
                                                                                
int main()                                                                      
{                                                                               
    int k;                                                                      
    int i,x;                                                                    
    int wynik[101];                                                             
    for (i=0; i<=100; i++) wynik[i]=-1;                                         
                                                                                

    int ost=100;                                                                
    cin >> k;                                                                   
                                                                                
    cout << ost << endl;                                                        
    i=1;                                                                        
    while (k>1)                                                                 
    {                                                                           
        if (k%2)                                                                
        {                                                                       

            wynik[i]=ost;                                                       
            k-=1;                                                               
            i++;
        } else                                                                  
        {                                                                       
            wynik[i]=i+2;                                                       
            k/=2;                                                               
	        i+=2;                                                                   
        }                                                                       
    }                                                                           
    for (i=1; i<ost; i++)                                                       
    {                                                                           
        cout << i+1 << " " << wynik[i] << endl;                                 
    }                                                                           
    cout << -1 << " " << -1 << endl;                                            
                                                                                
    return 0;                                                                   
}