華工校賽 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;
}

公式記錯 

發佈了41 篇原創文章 · 獲贊 3 · 訪問量 3797
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章