北京师范大学第十五届ACM决赛 D-Disdain Chain(竞赛图性质)

题目

思路来源

定理:任何竞赛图都有哈密顿路径,强连通的竞赛图有哈密顿回路

证明:https://blog.csdn.net/unsolvedmys/article/details/73608770

题解

竞赛图,相当于对C(n,2)条边的完全图定向,定为有向图

由定理,对于任意竞赛图,最长链长度都为n

所以,长度为1到n-1时输出0,为n时输出2的C(n,2)次方

代码

#include<bits/stdc++.h>
using namespace std;
int t,n;
int main()
{
    scanf("%d",&t);
    while(t--)
    {
        scanf("%d",&n);
        for(int i=1;i<n;++i)puts("0");
        printf("%lld\n",1ll<<(1ll*n*(n-1)/2));
    }
   return 0;
}
发布了467 篇原创文章 · 获赞 53 · 访问量 4万+

猜你喜欢

转载自blog.csdn.net/Code92007/article/details/103028524