Rectangular Congruences(构造题)

题意

给出矩阵对角元素,长为n,n为质数,构造矩阵使得

  • a ( r 1 , c 1 ) + a ( r 2 + c 2 ) ≠ a ( r 1 , c 2 ) + a ( r 2 , c 1 ) a(r_1,c_1)+a(r_2+c_2)\neq a(r_1,c_2)+a(r_2,c_1) a(r1,c1)+a(r2+c2)=a(r1,c2)+a(r2,c1)

constrains:
1 ≤ n ≤ 350 1\leq n\leq 350 1n350

思路

多移项!!!
a ( r 1 , c 1 ) − a ( r 1 , c 2 ) ≠ a ( r 2 , c 1 ) − a ( r 2 , c 2 ) a(r_1,c_1)-a(r_1,c_2)\neq a(r_2,c_1)-a(r_2,c_2) a(r1,c1)a(r1,c2)=a(r2,c1)a(r2,c2)
令第i行相邻元素差为i即可。
证明:
对于 1 ≤ k ≤ n − 1 1\leq k\leq n-1 1kn1,对于两行i,j有 k i ≠ k j ( m o d n ) ki\neq kj \pmod n ki=kj(modn)
k ( i − j ) ≠ 0 ( m o d n ) k(i-j)\neq 0 \pmod n k(ij)=0(modn),因为n是质数,k不是n的因子,所以只要 i ≠ j i\neq j i=j,上面的式子必能满足。

通式:
a i 2 + b i j + c j 2 + d i + e j + f ai^2+bij+cj^2+di+ej+f ai2+bij+cj2+di+ej+f,其中 b ≠ 0 ( m o d n ) b\neq 0 \pmod n b=0(modn)
只需要证明 a i j = b i j a_{ij}=bij aij=bij成立即可(我们发现对于好矩阵的某一行或者某一列加上一个常数,不会改变性质)
a r 1 , c 1 − a r 2 , c 1 − a r 1 , c 2 + a r 2 , c 2 = b ( r 1 − r 2 ) ( c 1 − c 2 ) a_{r1,c1}-a_{r2,c1}-a_{r1,c2}+a_{r2,c2}=b(r_1-r_2)(c_1-c_2) ar1,c1ar2,c1ar1,c2+ar2,c2=b(r1r2)(c1c2),n为质数时,显然成立。

构造思路怎么出来

  • 移项观察,对于思路放弃的胆量得大一点
  • 考虑迭代(数学归纳的过程),考虑对一个好的矩阵加上一个对角元素,我们发现对于好矩阵的某一行或者某一列加上一个常数,不会改变性质,这是添加元素形式的改造观察,比移项更难
  • 根据上一点可以推测,通式跟行和列是非线性相关的,应该有ij项,去探索ij项的特点。
  • ij项相减会满足移项中发现的性质。

代码

#include<bits/stdc++.h>
using namespace std;
#define pow2(X) (1ll<<(X))
#define SIZE(A) ((int)A.size())
#define LENGTH(A) ((int)A.length())
#define ALL(A) A.begin(),A.end()
#define F(i,a,b) for(ll i=a;i<=(b);++i)
#define dF(i,a,b) for(ll i=a;i>=(b);--i)
#define GETPOS(c,x) (lower_bound(ALL(c),x)-c.begin())
#define inf 0x3f3f3f3f
#define infll 0x3f3f3f3f3f3f3f3f
#define pb push_back
#define pr pair<int,int>
#define mkp make_pair
#define fi first
#define se second
#define eps 1e-6
#define PI acos(-1.0)
#define lb lower_bound
#define ub upper_bound
#define bs binary_search
#define FO(x) {freopen(#x".in","r",stdin);freopen(#x".out","w",stdout);}
#define Edg int M=0,fst[SZ],vb[SZ],nxt[SZ];void ad_de(int a,int b){++M;nxt[M]=fst[a];fst[a]=M;vb[M]=b;}void adde(int a,int b){ad_de(a,b);ad_de(b,a);}
#define Edgc int M=0,fst[SZ],vb[SZ],nxt[SZ],vc[SZ];void ad_de(int a,int b,int c){++M;nxt[M]=fst[a];fst[a]=M;vb[M]=b;vc[M]=c;}void adde(int a,int b,int c){ad_de(a,b,c);ad_de(b,a,c);}
#define es(x,e) (int e=fst[x];e;e=nxt[e])
#define esb(x,e,b) (int e=fst[x],b=vb[e];e;e=nxt[e],b=vb[e])
#define SZ 666666
typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> ipair;
typedef vector<int> VI;
typedef vector<long long> VLL;
typedef vector<vector<long long > > VVLL;
typedef vector<vector<int> > VVI;
typedef vector<double> VD;
typedef vector<string> VS;
const int mods = 998244353;
//const int mods = 1e9+7;
const int maxn = 1e5+10;
const int N = 5e5+10;
const int E = 1e4+10;
const int lim = 1e9;
ll qpow(ll a,ll b) {ll res=1;a%=mods; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mods;a=a*a%mods;}return res;}
ll lcm(ll a, ll b) {return a / __gcd(a, b) * b;}
int read(){ll x=0,f=1;char ch=getchar();while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}return x*f;}

ll n,m;
int a[400][400],b[400];

int main(){
	// freopen("C:\\Users\\Gao\\Desktop\\validation_input\\watering_well_chapter_2_input.txt","r",stdin);
	// freopen("C:\\Users\\Gao\\Desktop\\validation_input\\output.txt","w",stdout);
    
	ios_base::sync_with_stdio(0);
    int T;
    //cin>>T; 
	T = 1;
	F(turn,1,T){
		cin>>n;
		F(i,1,n){
			cin>>b[i];
		}
		F(i,1,n){
			a[i][i] = b[i];
		}
		F(i,1,n){
			F(j,1,n-1){
				a[i][(i+j-1)%n+1] = (a[i][((i+j-1)%n-1+n)%n+1] + i-1)%n;
			}
		}
		F(i,1,n){
			F(j,1,n){
				cout<<a[i][j]<<" \n"[j==n];
			}
		}
	}
}
 
/*
*/
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值