#include<cstdio>
#include<algorithm>
#include<utility>
using namespace std;
int k;
pair<int, int> connect[105];
int main(){
scanf("%d", &k);
for(int i = 1; i < 88; i++){
connect[i].first = i + 1;
if(i % 3 == 2) connect[i].second = i + 2;
}
for(int i = 29; i >= 0; i--){
if(k >= (1<<i)){
k -= (1<<i);
connect[(3*i) + 1].second = 89;
}
}
printf("89\n");
for(int i = 1; i <= 89; i++){
if(connect[i].first == 0) printf("-1 ");
else printf("%d ", connect[i].first);
if(connect[i].second == 0) printf("-1\n");
else printf("%d\n", connect[i].second);
}
return 0;
}
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 | #include<cstdio> #include<algorithm> #include<utility> using namespace std; int k; pair<int, int> connect[105]; int main(){ scanf("%d", &k); for(int i = 1; i < 88; i++){ connect[i].first = i + 1; if(i % 3 == 2) connect[i].second = i + 2; } for(int i = 29; i >= 0; i--){ if(k >= (1<<i)){ k -= (1<<i); connect[(3*i) + 1].second = 89; } } printf("89\n"); for(int i = 1; i <= 89; i++){ if(connect[i].first == 0) printf("-1 "); else printf("%d ", connect[i].first); if(connect[i].second == 0) printf("-1\n"); else printf("%d\n", connect[i].second); } return 0; } |
English