如果发现广告等破坏行为,请尽量将条目恢复到较早的版本而不是把相应内容直接删除,谢谢合作。

URAL/1512

来自"NOCOW"

跳转到: 导航, 搜索

就是构造啦~

#include <cstdio>
#include <cstdlib>
#include <cstring>
int N,K,t=0,ans[100001];
int main()
{
    scanf("%d",&N);
    K=(N>>1);
    if ((N%6 != 2) && (N%6 != 3))
    {
        int i=2;
        while (i <= N)
        {
            ans[++t]=i;
            i+=2;
        }
        i=1;
        while (i <= N)
        {
            ans[++t]=i;
            i+=2;
        }
    }
    else
    {
        int i=K;
        while (i <= N-(N&1)-(K&1))
        {
            ans[++t]=i;
            i+=2;
        }
        i=(1<<(K&1^1));
        while (i <= K-2)
        {
            ans[++t]=i;
            i+=2;
        }
        i=K+3;
        while (i <= N-(1<<(N&1)>>(K&1)))
        {
           ans[++t]=i;
           i+=2;
        }
        i=(1<<(K&1));
        while (i <= K+1)
        {
            ans[++t]=i;
            i+=2;
        }
        if (N&1)  ans[++t]=N;
    }
    for (int i=1;i<=N;i++)
        printf("%d %d\n",i,ans[i]);
    return 0;
}
//by zzy
个人工具