-
Notifications
You must be signed in to change notification settings - Fork 1
/
q3.txt
80 lines (61 loc) · 1.28 KB
/
q3.txt
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define pii pair<int , int>
#define int long long int
#define ALL(v) v.begin(),v.end()
#define ALLR(v) v.rbegin(),v.rend()
#define pi 3.14159265358979323
#define inf LLONG_MAX
#define ones(x) __builtin_popcount(x)
#define fill(a,b) memset(a,b,sizeof(a))
#define mod 1000000007
int mod_pow(int a,int b,int m)
{
int res = 1;
while(b)
{
if(b&1)
{
res = (res*a) % m;
}
a = (a*a) % m;
b >>= 1;
}
return res;
}
int mod_inverse(int a , int m)
{
return mod_pow(a , m - 2 , m);
}
void solve() {
int n;
cin >> n;
int ans;
vector< pii > d;
int now = n;
for(int i = n - 1; i >= 1; --i) {
int t = (now + i + 1) / 2;
d.pb({now , i});
ans = t;
now = t;
}
cout << ans << endl;
for(auto u : d) {
cout << u.F << " " << u.S << endl;
}
}
signed main() {
fast;
int t = 1;
cin >> t;
while(t--) {
solve();
}
return 0;
}