Educational Codeforces Round 85 (Rated for Div. 2) D. Minimum Euler Cycle(字典序最小的欧拉回路)
2020-04-14 14:05
513 查看
目录
- 传送门
- 题意:
- 思路:
- 代码:
传送门
题意:
思路:
构造的欧拉回路是
1 2 1 3 1 4 1 5……1 n
2 3 2 4 2 5……2 n
3 4 3 5……3 n
……
n-1 n
1
一共n*(n-1)+1个数
二分取[L,R]的数即可
代码:
#include <iostream> #include <stdio.h> #include <algorithm> #include <string.h> #include <vector> #include <math.h> #include <map> #include <queue> #include <set> #include <stack> #define pb push_back #define lb lower_bound #define ub upper_bound #define fi first #define se second #define all(x) (x).begin(),(x).end() #define SZ(x) ((int)(x).size()) #define debug(x) cout<<x<<endl #define rep(i,a,b) for(int i=a;i<=b;i++) #define per(i,a,b) for(int i=a;i>=b;i--) typedef long long ll; using namespace std; const int MAXN=1e5+50; const int inf=0x3f3f3f3f; const int mod=1e9+7; //::iterator it; ll a[MAXN]; int main() { std::ios::sync_with_stdio(false),cin.tie(0),cout.tie(0); ll n,l,r; int t; cin>>t; while(t--){ cin>>n>>l>>r; for(int i=1;i<=n-1;i++)a[i]=a[i-1]+2*(n-i); for(ll i=l;i<=r;i++){ if(i>a[n-1]){ cout<<1<<" "; continue; } auto pos=lower_bound(a+1,a+n,i)-a; //cout<<pos<<endl; int k=i-a[pos-1]; if(k&1)cout<<pos<<" "; else cout<<k/2+pos<<" "; } cout<<endl; } return 0; } /* */
- 点赞
- 收藏
- 分享
- 文章举报
相关文章推荐
- cf Educational Codeforces Round 85 (Rated for Div. 2)B. Middle Class
- cf Educational Codeforces Round 85 (Rated for Div. 2)A. Level Statistics
- Educational Codeforces Round 33 (Rated for Div. 2) F. Subtree Minimum Query (线段树)
- Educational Codeforces Round 33 (Rated for Div. 2) F - Subtree Minimum Query
- Educational Codeforces Round 33 (Rated for Div. 2) A题. Chess For Three
- Educational Codeforces Round 53 (Rated for Div. 2)
- Educational Codeforces Round 33 (Rated for Div. 2) C - Rumor
- Educational Codeforces Round 33 (Rated for Div. 2) A-C题解
- Educational Codeforces Round 63 (Rated for Div. 2)C - Alarm Clocks Everywhere
- Educational Codeforces Round 34 (Rated for Div. 2)
- 【codeforces 】Educational Codeforces Round 36 (Rated for Div. 2)(C.模拟 D.拓扑排序判断环)
- Educational Codeforces Round 39 (Rated for Div. 2) D - Timetable背包
- Educational Codeforces Round 40 (Rated for Div. 2) B. String Typing
- Educational Codeforces Round 56 (Rated for Div. 2) D
- Educational Codeforces Round 33 (Rated for Div. 2) E. Counting Arrays
- 【Educational Codeforces Round 53 (Rated for Div. 2)】
- Educational Codeforces Round 33 (Rated for Div. 2) B题. Beautiful Divisors
- Educational Codeforces Round 64 (Rated for Div. 2) B Ugly Pairs
- Educational Codeforces Round 64 (Rated for Div. 2)
- Educational Codeforces Round 65 (Rated for Div. 2) B. Lost Numbers