当前位置:网站首页>F.金玉其外矩阵(构造)
F.金玉其外矩阵(构造)
2022-08-04 14:09:00 【Harris-H】
F.金玉其外矩阵(构造)
不可能的情况就是矩阵长度分别整除,显然与2矛盾。
否则有解,考虑每个子矩阵右上角放负数,然后和为-1。最后肯定有多的行,直接正数即可。
选定的基数 m x mx mx要大于 n h × m w \dfrac{n}{h}\times \dfrac{m}{w} hn×wm,保证最终和为正数。
#include<bits/stdc++.h>
using namespace std;
long long n,m,h,w;
int main()
{
cin>>n>>m>>h>>w;
if(n%h==0&&m%w==0)
{
puts("N");
return 0;
}
int mx = (n/h)*(m/w)+1;
puts("Y");
for(int i=1;i<=n;i++)
{
for(int j=1;j<=m;j++)
{
if(i%h==0&&j%w==0)
{
printf("%d ",-mx*w*h+(mx-1));
}
else printf("%d ",mx);
}
printf("\n");
}
}
边栏推荐
- 干掉visio,这个画图神器真的绝了
- The Internet of things application development trend
- Problem solving-->Online OJ (18)
- 关于redis的几件小事(五)redis保证高并发以及高可用
- AlphaFold 如何实现 AI 在结构生物学中的全部潜力
- CCF GLCC officially opened | Kyushu Cloud open source experts bring generous bonuses to help universities promote open source
- Niuke.com Brush Question Record || Linked List
- 数据库恢复
- SQL语句的写法:Update、Case、 Select 一起的用法
- 浙江大学团队使用基于知识图谱的新方法,从空间分辨转录组数据中推断细胞间通信状况
猜你喜欢
随机推荐
Is the code more messy?That's because you don't use Chain of Responsibility!
工具函数---字符串处理
2042. 检查句子中的数字是否递增-力扣双百代码-设置前置数据
开放麒麟 openKylin 版本规划敲定:10 月发布 0.9 版并开启公测,12 月发布 1.0 版
LM2596有没有可以替代的?LM2576可以
Install mysql on k8s
FreeConfig.h文件
秋招攻略秘籍,吃透25个技术栈Offer拿到手软
Kyushu Cloud attended the Navigator Online Forum to discuss the current status, challenges and future of 5G MEC edge computing
如何才能有效、高效阅读?猿辅导建议“因材因时施教”
[LeetCode] 38. Appearance sequence
电子行业MES管理系统有哪些特殊功能
第六届未来网络发展大会,即将开幕!
How to install postgresql and configure remote access in ubuntu environment
Execution failed for task ‘:xxx:generateReleaseRFile‘.
"C pitfalls and pitfalls" reading summary
手搓一个“七夕限定”,用3D Engine 5分钟实现烟花绽放效果
c#之winform(软件开发)
物联网应用发展趋势
js深拷贝和浅拷贝具体使用区别_es6深拷贝和浅拷贝









