传送门

好神的构造题

vfk巨巨的题解

//minamoto
#include<bits/stdc++.h>
#define R register
#define fp(i,a,b) for(R int i=a,I=b+1;i<I;++i)
#define fd(i,a,b) for(R int i=a,I=b-1;i>I;--i)
#define go(u) for(int i=head[u],v=e[i].v;i;i=e[i].nx,v=e[i].v)
using namespace std;
char buf[1<<21],*p1=buf,*p2=buf;
inline char getc(){return p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++;}
int read(){
R int res,f=1;R char ch;
while((ch=getc())>'9'||ch<'0')(ch=='-')&&(f=-1);
for(res=ch-'0';(ch=getc())>='0'&&ch<='9';res=res*10+ch-'0');
return res*f;
}
char sr[1<<21],z[20];int C=-1,Z=0;
inline void Ot(){fwrite(sr,1,C+1,stdout),C=-1;}
void print(R int x,R char ch){
if(C>1<<20)Ot();if(x<0)sr[++C]='-',x=-x;
while(z[++Z]=x%10+48,x/=10);
while(sr[++C]=z[Z],--Z);sr[++C]=ch;
}
int n,m,now,tot,las,res,ans;
int main(){
// freopen("testdata.in","r",stdin);
n=read(),m=read();
for(R int i=1;(i+1)*(i+1)<=n;++i){
now=0,tot=n;
fd(j,i,1)now+=tot,tot-=2*j+1;
now+=tot;if(now>ans)ans=now,res=i;
}tot=las=0;
fd(i,res,1){
fp(j,1,(i<<1))printf("%d %d\n",tot+j,tot+j+1);
if(tot)printf("%d %d\n",las,tot+i+1);
las=tot+i+1,tot+=(i<<1)+1;
}if(!res)las=tot=1;
while(tot<n)printf("%d %d\n",las,++tot);
return 0;
}

最新文章

  1. 在​W​C​F​中​使​用​消​息​队​列​M​S​M​Q
  2. DNS(二)之构建域名解析缓存
  3. Sie sind das Essen und wir sind die Jaeger!
  4. DOM创建和删除节点、HTML DOM常用对象[转]
  5. Android开发遇到的异常及解决办法
  6. matlab实现复合梯形法则
  7. UVa 11489 (博弈) Integer Game
  8. 中文乱码的分析 和 从Eclipse设置启动JVM时的字符集(转)
  9. 如何打开Windows Server 2003 内存寻址扩展
  10. php中对MYSQL操作之批量运行,与获取批量结果
  11. windows phone 8.1开发:触控和指针事件1
  12. XIV Open Cup named after E.V. Pankratiev. GP of Europe
  13. vue整理
  14. elasticsearch 摘要
  15. Java调用FFmpeg进行视频处理及Builder设计模式的应用
  16. (转载)Unity UGUI鼠标点击UI不受影响方法IsPointerOverGameObject
  17. div等比例缩放-------纯CSS实现自适应浏览器宽度的正方形
  18. python 基础1
  19. MapReduce计算之——hadoop中的Hello World
  20. Django ORM之QuerySet

热门文章

  1. protoc: error while loading shared libraries: libprotoc.so.9: cannot open shared object
  2. NSArray / NSSet / NSDictory 三者的异同点
  3. 一篇文章搞明白CORS跨域
  4. 程序移植到VS2010,编译成功但是无法启动lib文件
  5. win7下使用source insight,没有Courier字体
  6. zoj 2316 Matrix Multiplication 解题报告
  7. golang 关于golang.org/x包问题
  8. ubuntu中使用gensim+word2vec[备忘]
  9. 如何配置xmanager
  10. QQ登陆功能的实现2