1 条题解

  • 2
    @ 2023-8-25 16:46:54
    #include <bits/stdc++.h>
    using namespace std;
    int main()
    {
        int n;
        cin >> n;
        if (n == 1 || n == 3 || n == 9)
            cout << "NO";
        else if (n == 2)
            cout << "1 2 " << endl << "4 3 ";
        else if (n == 4)
        {
            cout << "1 2 11 12" << endl;
            cout << "4 15 8 5" << endl;
            cout << "7 16 3 14" << endl;
            cout << "6 13 10 9" << endl;
        }
        else if (n == 5)
        {
            cout << "1 2 3 4 7" << endl;
            cout << "6 5 14 15 16 " << endl;
            cout << "13 24 23 8 21 " << endl;
            cout << "10 19 18 11 20 " << endl;
            cout << "9 22 25 12 17 " << endl;
        }
        else if (n == 6)
        {
            cout << "1 2 3 4 7 6" << endl;
            cout << "10 27 34 19 24 5 " << endl;
            cout << "13 16 25 18 35 26" << endl;
            cout << "30 31 12 29 32 21 " << endl;
            cout << "11 36 17 14 9 22 " << endl;
            cout << "8 23 20 33 28 15 " << endl;
        }
        else if (n == 7)
        {
            cout << "1 2 3 4 7 6 5 " << endl;
            cout << "10 21 16 13 46 37 42 " << endl;
            cout << "9 32 15 28 43 24 19 " << endl;
            cout << "8 29 38 33 40 49 22 " << endl;
            cout << "11 30 41 26 27 34 45 " << endl;
            cout << "12 31 48 35 44 39 14 " << endl;
            cout << "17 36 25 18 23 20 47 " << endl;
        }
        else if (n == 8)
        {
            cout << "1 2 3 4 7 6 5 8 " << endl;
            cout << "10 21 20 27 52 61 48 11 " << endl;
            cout << "9 22 51 62 45 28 55 12 " << endl;
            cout << "14 57 50 39 34 25 54 17 " << endl;
            cout << "15 26 33 64 19 42 59 44 " << endl;
            cout << "16 63 46 37 24 29 38 35 " << endl;
            cout << "13 40 43 36 23 60 41 32 " << endl;
            cout << "18 49 58 31 30 53 56 47 " << endl;
        }
        else
        {
            cout << "1 2 3 4 7 6 5 8 9 10" << endl;
            cout << "12 29 38 33 34 25 36 23 44 27" << endl;
            cout << "11 30 41 26 45 22 31 48 35 32" << endl;
            cout << "18 43 60 47 56 51 28 19 24 65" << endl;
            cout << "13 40 49 54 53 50 39 64 37 42" << endl;
            cout << "16 21 52 55 84 89 62 75 76 97" << endl;
            cout << "15 58 79 72 95 68 69 82 91 66" << endl;
            cout << "14 93 88 85 96 83 98 81 100 73" << endl;
            cout << "17 86 63 46 67 90 59 92 99 94" << endl;
            cout << "20 77 74 57 70 61 78 71 80 87" << endl;
        }
        return 0;
    }
    

    非常非常非常非常非常非常非常非常非常非常非常非常非常非常非常非常非常非常非常非常非常非常非常非常非常非常非常非常非常非常非常非常非常非常非常非常非常非常简洁的代码(doge

    • 1

    信息

    ID
    1774
    时间
    1000ms
    内存
    256MiB
    难度
    10
    标签
    递交数
    16
    已通过
    0
    上传者