CF989C A Mist of Florescence
2024-09-06 05:47:28
思路:
有趣的构造题。
实现:
#include <bits/stdc++.h>
using namespace std;
char ans[][];
void fillin(int x, int y, char c, int maxy, int cnt)
{
int a = x, b = y;
while (cnt)
{
ans[a][b] = c;
if (b + >= maxy) { a += ; b = y; }
else b += ;
cnt--;
}
}
int main()
{
int a, b, c, d;
while (cin >> a >> b >> c >> d)
{
for (int i = ; i < ; i++)
{
for (int j = ; j < ; j++)
{
ans[i][j] = 'A';
ans[i][j + ] = 'B';
ans[i + ][j] = 'C';
ans[i + ][j + ] = 'D';
}
}
fillin(, , 'B', , b - );
fillin(, , 'C', , c - );
fillin(, , 'D', , d - );
fillin(, , 'A', , a - );
cout << "50 50" << endl;
for (int i = ; i < ; i++)
{
for (int j = ; j < ; j++)
cout << ans[i][j];
cout << endl;
}
}
return ;
}
总结:
对于构造题,要尽量用简单的方法完成任务,不要自己徒增限制条件。
最新文章
- Window下python2.7+Apache+mod_wsgi+Django服务器配置
- jquery.get()
- MySql的连接查询
- 回文串+回溯法 URAL 1635 Mnemonics and Palindromes
- cocos2d-x 开启深度测试验 实现 遮挡
- 设计模式-单键(Singleton)
- iOS开发——生成二维码——工具类
- JS对undefined,null,NaN判断
- lua转让C++书面DLL达到“热更新”
- ubuntu14.04 安装 tensorflow
- 详解meta标签
- MapReduce:并行计算框架
- React Native移植原生Android
- 使用find命令查找文件
- JavaScript异步流程控制的前世今生
- 使用 PLSQL 连接 Oracle9i 数据库
- antd tree组件文件名换行 + 点击展开时,自动收起同级其他展开目录
- PHP抓取网页内容经验总结
- WinPE ISO制作
- go 切片练习