华工校赛 H-对称与反对称

#include <cstdio>
#include <iostream>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <bitset>
#include <vector>
#include <string>
#include <stack>
#pragma comment(linker, "/STACK:1024000000,1024000000")
using namespace std;
typedef long long ll;
ll a[1010][1010];
ll b[1010][1010];
int main()
{

    int n,m;
    while(scanf("%d%d",&n,&m)!=EOF)
    {
        for(int i=1; i<=n; i++)
        {
            for(int j=1; j<=n; j++)
            {
                scanf("%lld",&a[i][j]);
                //a[i][j]%=m;
            }
        }
        for(int i=1; i<=n; i++)
        {
            for(int j=1; j<=n; j++)
            {
                ll x=a[i][j]-a[j][i];
                if(x%2)x-=m;
                b[i][j]=x/2;
            }
        }
        for(int i=1; i<=n; i++)
        {
            for(int j=1; j<=n; j++)
            {
                while(b[i][j]<0) b[i][j]+=m;
                printf("%lld",b[i][j]);
                if(j!=n) cout<<' ';
            }
            cout<<endl;
        }
    }
    return 0;
}

公式记错 

猜你喜欢

转载自blog.csdn.net/weixin_39302444/article/details/79845158
今日推荐