首页 > 其他分享 >Codeforces Round #822 (Div. 2) D

Codeforces Round #822 (Div. 2) D

时间:2023-01-25 12:45:48浏览次数:59  
标签:r1 r2 int Codeforces 400 c2 Div c1 822

链接:https://codeforces.com/problemset/problem/1734/E
题意,给定n,b[1~n],求一个nn矩阵,满足a[i][i]=b[i],且对于r1<r2,c1<c2,a[r1][c1]+a[r2][c2]!=a[r1][c2]+a[r2][c1](mod n). n<=350,保证n为质数。
这个式子不好切入,进行变形:a[r1][c1]-a[r1][c2]!=a[r2][c1]-a[r2][c2]%n , a[r1][c1]-a[r2][c1]!=a[r1][c2]-a[r2][c2]%n.
即任意两行(列)对应两数差值不等,对整体即为p1,p2,a[i][p1]-a[i][p2](1<=i<=n)遍历n的完全剩余系,考虑构造方案,经尝试,发现只需对第i列使得第j+1数与第j数差值%n下为i-1. 对于每个b[i],平移序列即可。
证明:对于任意两列,显然差值分别为(c1-1)
d,(c2-1)d,而n为素数,故(c1-1)d-(c2-1)*d=0 mod n 当且仅当n |c1-c2 .显然不可能。对于任意两行,对应位置差值易知遍历完系,故成立。
代码:

#define int long long 
using namespace std;
const int N=3e5+100;
int b[400],g[400][400];
signed main()
{
	int n;
	cin>>n;
	for(int i=1;i<=n;i++) cin>>b[i];
	for(int i=1;i<=n;i++)
	{
		int cnt=0;
		for(int j=i;cnt<n;cnt++,j=j%n+1)
		{
			g[i][j]=(b[i]+cnt*(i-1))%n;
		}
	}
	for(int i=1;i<=n;i++)
	{
	for(int j=1;j<=n;j++)
	cout<<g[i][j]<<" ";
	cout<<endl;
	}
}

标签:r1,r2,int,Codeforces,400,c2,Div,c1,822
From: https://www.cnblogs.com/wjhqwq/p/17066846.html

相关文章

  • CodeForces-907#B 题解
    正文设数组\(c_{x,y,i,j}\)代表\((x,y)\)位置的大格子中\((i,j)\)位置的小格子。很显然,输入中字符的输入顺序是要调整的,实际的顺序是\(x,i,y,j\)。对于输入的\(......
  • Codeforces Round #845 (Div. 2) and ByteRace 2023 A-D
    CodeforcesRound#845(Div.2)andByteRace2023A-DA.EverybodyLikesGoodArrays!题意:对给定数组进行操作:删除相邻两项,替换为两项的乘积,使得该数组奇偶相间。......
  • JavaScript: div,textarea set or get value
    <!doctypehtml><html><head><metacharset="utf-8"><metaname="viewport"content="width=device-width,initial-scale=1.0,maximum-scale=1.0,minimum-scale=1.0,u......
  • CF Div2 Round 845
    A注意到奇数和奇数的乘积仍是奇数。偶数和偶数的乘积仍是偶数。所以答案就是\(n\)减去奇偶连续段段个数。#include<cstdio>#include<vector>usingnamespacestd......
  • Codeforces Round #845 (Div. 2) and ByteRace 2023
    《B.Emordnilap》数学,思维   题意:给定一个由1~n组成序列,然后将这序列复制,反转,再放到原序列的末尾,得到新的序列(设为s)问s的逆序对个数 当时我写......
  • Codeforces Round #845 (Div. 2) D题解
    D.ScoreofaTree题目链接:https://codeforces.com/contest/1777/problem/D个人感觉还是比较简单的一道计数题题意是给你一颗有n(n<=2e5)节点的树,初始时每个节点有一个......
  • 【题解】Codeforces Round #845 (Div. 2) and ByteRace 2023
    建议开题顺序:A->B->C->F->E->D诈骗差评,典题差评,想易写难数据结构差评。A.EverybodyLikesGoodArrays!好像是结论题,但是一力降十会。显然最后合并完后,每个......
  • B. Emordnilap【Codeforces Round #845 (Div. 2) and ByteRace 2023】
    B.Emordnilap原题链接Apermutationoflengthnisanarrayconsistingofndistinctintegersfrom1toninarbitraryorder.Forexample,[2,3,1,5,4]isape......
  • A. Everybody Likes Good Arrays!【Codeforces Round #845 (Div. 2) 】
    A.EverybodyLikesGoodArrays!原题链接Anarrayaisgoodifforallpairsofadjacentelements【相邻元素】,aiandai+1(1≤i<n)areofdifferentparity【奇......
  • Educational Codeforces Round 1 个人总结A-E
    EducationalCodeforcesRound1A.TrickySum数学,求\(1\dotsn\)的和减去小于等于n的二次幂乘2之和LLf[40];voidsolve(){ LLn; cin>>n; LLans=n+n*(n-1)/2;......