codeforces710c

原创 2016年08月28日 22:42:50

幻方,这个就是,题意是,用1~n方个数,来构造,横行,竖行,斜行,都是奇数。
你可以这样啊,就是,让奇数构造在正方形中形成一个菱形。以五为例,第一行,中间1个奇数,第二行,中间3个奇数,第三个行,中间5个奇数。第四行中间3个奇数,第五行中间1个奇数

#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int main()
{
    int ji = 1 , ou = 2 , n ;
    scanf("%d",&n);
    for(int i = 1 ; i <= n ; i++){
        for(int j = 1 ; j <= abs((n + 1) / 2 - i ); j++)
            printf("%d ", ou),ou += 2;
        for(int j = 1 ; j <= n - 2*abs((n + 1) / 2 - i) ; j++)
            printf("%d ", ji),ji += 2;
        for(int j = 1 ; j <= abs((n + 1) / 2 - i ); j++)
            printf("%d ", ou),ou += 2;
        printf("\n");
    }
    return 0;
}
版权声明:随便转咯,就是赚点币子

CodeForces-710C Magic Odd Square(幻方问题/构造)

C. Magic Odd Square time limit per test 1 second memory limit per test 256 megabytes input sta...

Codeforces Problem 710C Magic Odd Square

Codeforces Problem 710C Magic Odd Square

Codeforces 710C Magic Odd Square【思维】

C. Magic Odd Square time limit per test 1 second memory limit per test 256 megabytes inpu...

codeforces 710C C. Magic Odd Square

Find an n × n matrix with different numbers from 1 to n2, so the sum in each row, column and both ma...

Codeforces 710 C. Magic Odd Square(构造)——Educational Codeforces Round 16

传送门Find an n × nn × n matrix with different numbers from 11 to n2n^2, so the sum in each row, colum...

线性同余方程及例题 codeforces 710D

简述⎧⎩⎨⎪⎪⎪⎪⎪⎪⎪⎪x≡r1(modm1)x≡r2(modm2)x≡r3(modm3)……\left\{ \begin{aligned} x ≡ r_1 \pmod{m_1} \\ x ≡ r_...

Codeforces Problem 710A King Moves(implementation)

Codeforces Problem 710A King Moves(implementation)

codeforces 710E Generate a String [dp]【动态规划】

题目链接:http://codeforces.com/problemset/problem/710/E ————————————————-. E. Generate a String time ...

【数论】【扩展欧几里得】Codeforces 710D Two Arithmetic Progressions

题目链接:   http://codeforces.com/problemset/problem/710/D 题目大意:   两个等差数列a1x+b1和a2x+b2,求L到R区间...

Codeforces 710E Generate a String【dp】好题!

E. Generate a String time limit per test 2 seconds memory limit per test 512 megabytes in...
内容举报
返回顶部
收藏助手
不良信息举报
您举报文章:codeforces710c
举报原因:
原因补充:

(最多只允许输入30个字)