ZOJ - 4032 Magic Points

题目链接:

http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=4032

所要连成的直线一定是斜率不相等并且交点一定是两个直线相交。

按照下面图的规律找点就可以了。

代码如下:

//include <bits/stdc++.h>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#include <stack>
#include <time.h>
#include <vector>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <functional>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll MOD =  10007;
const int maxn = 2*1e5+5;
const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3f;
template <class T>
inline bool scan_d(T &ret) {
	char c; int sgn;
	if (c = getchar(), c == EOF) return 0;
	while (c != '-' && (c<'0' || c>'9')) c = getchar();
	sgn = (c == '-') ? -1 : 1;
	ret = (c == '-') ? 0 : (c - '0');
	while (c = getchar(), c >= '0'&&c <= '9') ret = ret * 10 + (c - '0');
	ret *= sgn;
	return 1;
}
int t;
int n;

int main()
{
    scanf("%d",&t);
    while(t--)
    {
        scanf("%d",&n);
        if(n==2)
        {
            printf("0 2 1 3\n");
            continue;
        }
        for (int i=3*n-3,j=1;i<4*n-4;i++,j++)
        {
            printf("%d %d ",i,j);
        }
        printf("%d %d\n",n,2*n-1);
    }
	return 0;
}

猜你喜欢

转载自blog.csdn.net/qq_41410799/article/details/89602901
ZOJ