璟雯院

珺璟如晔,雯华若锦

用户工具

站点工具


icpc:problems:701d_multiples_and_power_differences
problems
名称Multiples and Power Differences
题目编号701D
题目链接codeforces.com/…
来源CodeForces
算法分类构造
难易程度一般般

Multiples and Power Differences

想法

构造题,怎么想都不知道怎么构造。

其实看看数据范围a才只有16.所以直接720720,然后差异化就用a的4次方就好。

按照i+j的奇偶性来组棋盘。

代码实现

#include<cstdio>//uncle-lu 701 d
#include<cmath>
#include<algorithm>
template<class T>void read(T &x)
{
	x=0;int f=0;char ch=getchar();
	while(ch<'0'||ch>'9') { f|=(ch=='-'); ch=getchar(); }
	while(ch<='9'&&ch>='0') { x=(x<<1)+(x<<3)+(ch^48); ch=getchar(); }
	x = f ? -x : x;
	return ;
}
 
int map[510][510];
int n, m;
 
int main()
{
	read(n);read(m);
	for(int i=1; i<=n; ++i)
		for(int j=1; j<=m; ++j)
			read(map[i][j]);
 
	for(int i=1; i<=n; ++i)
	{
		for(int j=1; j<=m; ++j)
		{
			if((i+j)%2 == 1)
				printf("%d ", 720720);
			else
				printf("%d ", 720720+map[i][j]*map[i][j]*map[i][j]*map[i][j]);
		}
		printf("\n");
	}
 
	return 0;
}
/app/www/public/data/pages/icpc/problems/701d_multiples_and_power_differences.txt · 最后更改: 2023/10/01 10:41 由 温婕莺