当前位置:网站首页>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");
}
}
边栏推荐
- MPLS experiment
- idea permanent activation tutorial (new version)
- eyb:JWT介绍
- Lixia Action | Kyushu Yunzhang Jinnan: Open source is not a movement for a few people, popularization is the source
- 【毕设选题推荐】机器人工程专业毕设选题推荐
- 并发程序的隐藏杀手——假共享(False Sharing)
- 阿里老鸟终于把测试用例怎么写说的明明白白了,小鸟必看
- How to play the Tower of Hanoi
- 博途1200/1500PLC斜坡指令RAMP(带暂停功能)
- "C pitfalls and pitfalls" reading summary
猜你喜欢
随机推荐
字符串类的设计与实现_C语言字符串编程题
js深拷贝和浅拷贝具体使用区别_es6深拷贝和浅拷贝
七夕当然要学会SQL优化好早点下班去找对象
电子行业MES管理系统有哪些特殊功能
爬虫——动作链、xpath、打码平台使用
Button control switch 4017 digital circuit chip
Kyushu Cloud attended the Navigator Online Forum to discuss the current status, challenges and future of 5G MEC edge computing
FreeConfig.h文件
MySQL性能指标TPS\QPS\IOPS如何压测?
Convolutional Neural Network Basics
MySQL【窗口函数】【共用表表达式】
SQL语句的写法:Update、Case、 Select 一起的用法
Lixia Action | Kyushu Yunzhang Jinnan: Open source is not a movement for a few people, popularization is the source
Crawler - action chain, xpath, coding platform use
将 Sentinel 熔断限流规则持久化到 Nacos 配置中心
Rust 从入门到精通04-变量
【无标题】
Keycloak 6.0.0 正式发布,身份和访问管理系统
开发者独立搭建一个跨模态搜索应用有多难?
文盘Rust -- 配置文件解析