codeforces#240_div2_C Mashmokh and Numbers
来源:互联网 发布:单机版考试软件 编辑:程序博客网 时间:2024/05/22 04:26
题目地址:点这里
构造一个数列,没有重复的数据,这里的关键就是(n,n+1)==1 .
然后,最后一对把之前的都补上来,但是,要注意是否会出现重复,那么只要有可能出现的,就取一般取不到的max-(t1++), max-(t2++).
但是它们只相差一个,所有还要再(t1++,t2++).
要注意特判啊,n==1 时,不能得分的, 这样就要看k==0?
代码:
#include<iostream>#include<set>using namespace std;int maxn=1000000000;set<int> s;int main(){ int n,k; cin>>n>>k; int t1=1; int t2=2; if(n%2==0) { if(k<n/2) cout<<-1<<endl; else if(k==n/2) { for(int i=0;i<n;i++) { if(i) cout<<' '; cout<<i+1; } cout<<endl; } else { for(int i=1;i<=(n-2)/2;i++) { if(2*i!=k-(n-2)/2&&2*i+1!=k-(n-2)/2&&2*i!=2*(k-(n-2)/2)&&2*i+1!=2*(k-(n-2)/2)) cout<<2*i<<' '<<2*i+1<<' '; else { cout<<maxn-(t1++)<<' '<<maxn-(t2++)<<' '; t1++; t2++; } } cout<<k-(n-2)/2<<' '<<2*(k-(n-2)/2)<<endl; } } else { if(n==1) { if(k==0) { cout<<814<<endl; return 0; } else{ cout<<-1<<endl; return 0; } } //cout<<"jingqi"<<endl; n--; if(k<n/2) cout<<-1<<endl; else if(k==n/2) { for(int i=0;i<n;i++) { if(i) cout<<' '; cout<<i+1; } cout<<' '<<maxn<<endl; } else { for(int i=1;i<=(n-2)/2;i++) { if(2*i!=k-(n-2)/2&&2*i+1!=k-(n-2)/2&&2*i!=2*(k-(n-2)/2)&&2*i+1!=2*(k-(n-2)/2)) cout<<2*i<<' '<<2*i+1<<' '; else { cout<<maxn-(t1++)<<' '<<maxn-(t2++)<<' '; t1++; t2++; } } cout<<k-(n-2)/2<<' '<<2*(k-(n-2)/2)<<' '<<maxn-(t1+3)<<endl; } }}
0 0
- codeforces#240_div2_C Mashmokh and Numbers
- Codeforces Round #240 (Div. 2) C. Mashmokh and Numbers
- Codeforces Round #240 (Div. 2) Mashmokh and Numbers
- Codeforces 414A Mashmokh and Numbers(构造)
- CodeForces 414A Mashmokh and Numbers
- CodeForces 414A Mashmokh and Numbers
- A. Mashmokh and Numbers
- A. Mashmokh and Numbers
- CodeForces 414A Mashmokh and Numbers(模拟)
- CodeForces 414A Mashmokh and Numbers(模拟)
- codeforces 414A Mashmokh and Numbers 模拟题
- Mashmokh and ACM(Codeforces Round #240)
- codeforces#240_div2_B Mashmokh and Tokens
- codeforces Mashmokh and Tokens
- CF---C. Mashmokh and Numbers
- Codeforces Round #215_div2_C. Sereja and Algorithm
- Codeforces Round #240 (Div. 2) A. Mashmokh and Lights
- Codeforces Round #240 (Div. 2)B. Mashmokh and Tokens
- C#与Java的一些小异同
- Key Performance Counters and their thresholds for Windows Server
- 数据管理_MDB空间数据库再探
- linux c语言 select函数用法
- OM设置摘要知识点
- codeforces#240_div2_C Mashmokh and Numbers
- PHP数组与java数组的区别
- mysql 基础笔记
- Android应用如何监听自己是否被卸载及卸载反馈功能的实现
- ios开发(6)uiimageView
- Windows 消息 机制
- 在 Eclipse 里使用 Java 6 注解处理器
- 游戏开发入门
- vtk读取obj文件和贴图