新手不会啊。。。。。。。

每一个事物都能战胜另外两种事物,但是同时也被其他两种事物克制,这就是传说中的一环克一环,而且我们认为这是很公平的游戏。

现在给你们n个事物,这n个事物到底能不能组成一个公平的游戏,如果可以输出Yes,不行输出No
输入要求
输入一个整数n(2 <= n <= 2^30)表示有n个事物来组建游戏
输出要求
每次输出占一排,如果可以组成公平的游戏输出Yes,如果不行输出No。

 using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            int[,] arr = new int[n, n];
            Func<int, int, int, int> FindObj = new Func<int, int, int, int>((me, start, result) =>
            {
                for (int i = start; i < n; i++)
                    if (arr[me, i] == result) return i;
                return -1;
            });
            Func<int, int, int> MarkObj = new Func<int, int, int>((me, result) =>
            {
                for (int i = 0; i < n; i++)
                {
                    if (arr[me, i] == 0)
                    {
                        arr[me, i] = result;
                        arr[i, me] = (result == 1) ? 2 : 1;
                        return i;
                    }
                }
                return -1;
            });
            Func<int, int, bool> Check = new Func<int, int, bool>((me, result) =>
            {
                int count = 0;
                int start = 0;
                while (count < 2)
                {
                    int r = FindObj(me, start, result);
                    if (r == -1)
                    {
                        if (MarkObj(me, result) == -1) return false;
                    }
                    else
                    {
                        start = r + 1;
                    }
                }
                return true;
            });
            Func<bool> Solve = new Func<bool>(() =>
            {
                for (int i = 0; i < n; i++)
                {
                    if (!Check(i, 1) || !(Check(i, 2))) return false;
                }
                return true;
            });
            Console.WriteLine(Solve());
        }
    }
}

5
True
        胜      胜      负      负
负              胜      胜      负
负      负              胜      胜
胜      负      负              胜
胜      胜      负      负
Press any key to continue . . . 
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            int[,] arr = new int[n, n];
            Action Display = new Action(() =>
            {
                for (int i = 0; i < n; i++)
                {
                    for (int j = 0; j < n; j++)
                    {
                        Console.Write((arr[i, j] == 1 ? "胜" : (arr[i, j] == 2 ? "负" : "")) + "\t");
                    }
                    Console.WriteLine();
                }
            });
            Func<int, int, int, int> FindObj = new Func<int, int, int, int>((me, start, result) =>
            {
                for (int i = start; i < n; i++)
                    if (arr[me, i] == result) return i;
                return -1;
            });
            Func<int, int, int> MarkObj = new Func<int, int, int>((me, result) =>
            {
                for (int i = 0; i < n; i++)
                {
                    if (me != i && arr[me, i] == 0)
                    {
                        arr[me, i] = result;
                        arr[i, me] = (result == 1) ? 2 : 1;
                        return i;
                    }
                }
                return -1;
            });
            Func<int, int, bool> Check = new Func<int, int, bool>((me, result) =>
            {
                int count = 0;
                int start = 0;
                while (true)
                {
                    int r = FindObj(me, start, result);
                    if (r == -1)
                    {
                        if (count < 2)
                        {
                            if (MarkObj(me, result) == -1) return false;
                        }
                        else
                        {
                            break;
                        }
                    }
                    else
                    {
                        count++;
                        start = r + 1;
                    }
                }
                return count == 2;
            });
            Func<bool> Solve = new Func<bool>(() =>
            {
                for (int i = 0; i < n; i++)
                {
                    if (!Check(i, 1) || !(Check(i, 2))) return false;
                }
                return true;
            });
            Console.WriteLine(Solve());
            Display();
        }
    }
}

http://blog.csdn.net/runner__1/article/details/52564227

这个题其实就是判断奇偶数,奇数输出yes,偶数输出no……具体题解见我之前发的链接