CodeForces - 277B Set of Points

Convexity of a set of points on the plane is the size of the largest subset of points that form a convex polygon. Your task is to build a set of n points with the convexity of exactly m. Your set of points should not contain three points that lie on a straight line.

Input

The single line contains two integers n and m (3 ≤ m ≤ 100, m ≤ n ≤ 2m).

Output

If there is no solution, print "-1". Otherwise, print n pairs of integers — the coordinates of points of any set with the convexity of m. The coordinates shouldn't exceed 108 in their absolute value.

Examples

Input

4 3

Output

0 0
3 0
0 3
1 1

Input

6 3

Output

-1

Input

6 6

Output

10 0
-10 0
10 1
9 1
9 -1
0 -2

Input

7 4

Output

176166 6377
709276 539564
654734 174109
910147 434207
790497 366519
606663 21061
859328 886001

题意:输出n个点,最多可以选出m个点组成凸多边形

   

题解:通过画图,如图若已有 ABCD点,因为不能三点相交,所以若在增加一点E在1区域,会形成BEDA 4个点的凸多边形,若在2区域会形成BEDC,若在区域3,会形成AEDC,(右边三个区域同理),若在区域4,形成AEBC,所以当m==3时n<=4符合,

接下来我们就看怎么形成m的凸多边形了,因为题中给出m*2>=n ,注意这个条件

我们可以以(0,0) 为基础点 构造出 相邻两点斜率不断增加的图形,如 (1,1) (2,3) (3,6) ...构造出m个后 剩余n-m个对称的构造出来就行了,注意的是 最高点要多输出一次,不能到达最高后,接着往下输出,否则如果m==n/2 的话,按照右半部分,就会有m+1个点构成凸多边形,还有就是注意三点不要在一条直线上,因为m<=100 前m个点两点间最大斜率为99 所以在第m+1个点的x在 10000之后就可以了,就这个地方没注意到,老是错....

#include<bits/stdc++.h>
using namespace std;
int n,m;
int main()
{
	scanf("%d%d",&n,&m);
	if(m==3&&(n>4))
	{
		printf("-1\n");
		return 0;
	}
	int cnt=0,y=0;
	for(int i=0;i<m;i++)
		printf("%d %d\n",i,y=y+cnt++);
	if(m<n) printf("%d %d\n",m+100000,y);
	for(int i=m+1;i<n;i++)
		printf("%d %d\n",i+100000,y=y-(--cnt));
	return 0;
} 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值