rt,本来以为是long long,结果发现开了unsigned long long都不行。。。。。。
#include <bits/stdc++.h>
using namespace std;
#define int unsigned long long
const int N = 1e6 + 5;
int Left, Right;
int AnswerSize = 0;
int AnswerLeft[N], AnswerRight[N];
signed main () {
cin >> Left >> Right;
while (Left != Right) {
int i = 0;
while (Left % (1 << (i + 1)) == 0 && Left + (1 << (i + 1)) <= Right) {
++i;
}
AnswerLeft[++AnswerSize] = Left;
AnswerRight[AnswerSize] = Left + (1 << i);
Left += (1 << i);
}
cout << AnswerSize << endl;
for (int i = 1; i <= AnswerSize; ++i) {
cout << AnswerLeft[i] << ' ' << AnswerRight[i] << endl;
}
return 0;
}
第三个样例会TLE