1 条题解
-
0
#include<bits/stdc++.h> #define int long long using namespace std; #define MAX_SIZE 8888 queue<pair<int, int>> q; vector<pair<int, int>> ans; bool cmp(pair<int, int> a, pair<int, int> b){ return a.first < b.first; } signed main(){ int n, m; cin >> n >> m; q.push({n, m}); while(!q.empty()){ int x = q.front().first; int y = q.front().second; q.pop(); if (x <= (y - x)){ q.push({x, (x + y) / 2}); q.push({(x + y) / 2 + 1, y}); } else { ans.push_back({x, y}); } } sort(ans.begin(), ans.end(), cmp); cout << ans.size() << "\n"; for (auto it = ans.begin(); it != ans.end(); it++){ cout << it->first << ' ' << it->second << "\n"; } return 0; }
- 1
信息
- ID
- 96
- 时间
- 1000ms
- 内存
- 256MiB
- 难度
- 7
- 标签
- (无)
- 递交数
- 43
- 已通过
- 9
- 上传者