当前位置:网站首页>HZOJ #240. Graphic printing IV
HZOJ #240. Graphic printing IV
2022-07-07 12:50:00 【Duange】
subject :240. Graphic printing IV
Subject portal :240 topic
The sample input
1
2
3
4
-1
Sample output
X
-
X X
X
X X
-
X X X X
X X
X X X X
X X
X
X X
X X X X
X X
X X X X
-
X X X X X X X X
X X X X
X X X X X X X X
X X X X
X X
X X X X
X X X X X X X X
X X X X
X X X X X X X X
X X X X
X X
X X X X
X X
X
X X
X X X X
X X
X X X X
X X X X X X X X
X X X X
X X X X X X X X
X X X X
X X
X X X X
X X X X X X X X
X X X X
X X X X X X X X
-
Data scale and agreement
The time limit :1 s
Memory limit :256 M
100% Data assurance for 1≤n≤7
Code
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
using namespace std;
char ans[1005][1005];
int num[10] = { 0,1,3,9,27,81,243,729 };
void func(int x, int y, int n)
{
if (n == 1) {
ans[x][y] = 'X';
return;
}
func(x, y, n - 1);
func(x, y + num[n] / 3 * 2, n - 1);
func(x + num[n] / 3 * 2, y, n - 1);
func(x + num[n] / 3, y + num[n] / 3, n - 1);
func(x + num[n] / 3 * 2, y + num[n] / 3 * 2, n - 1);
}
int main()
{
func(1, 1, 7);
int n;
while (cin >> n)
{
if (n == -1) {
break;
}
for (int i = 1; i <= num[n]; i++)
{
for (int j = 1; j <= num[n]; j++)
{
if (ans[i][j] == 'X') {
cout << 'X';
}
else {
cout << ' ';
}
}
cout << endl;
}
cout << '-' << endl;
}
return 0;
}
边栏推荐
- How to use PS link layer and shortcut keys, and how to do PS layer link
- Charles: four ways to modify the input parameters or return results of the interface
- Realize all, race, allsettled and any of the simple version of promise by yourself
- Leetcode skimming: binary tree 20 (search in binary search tree)
- 有什么类方法或是函数可以查看某个项目的Laravel版本的?
- [learn microservices from 0] [03] explore the microservice architecture
- How to apply @transactional transaction annotation to perfection?
- Master formula. (used to calculate the time complexity of recursion.)
- Leetcode brush questions: binary tree 19 (merge binary tree)
- 【PyTorch实战】图像描述——让神经网络看图讲故事
猜你喜欢
Master formula. (used to calculate the time complexity of recursion.)
About IPSec
Talk about four cluster schemes of redis cache, and their advantages and disadvantages
处理链中断后如何继续/子链出错removed from scheduling
Aike AI frontier promotion (7.7)
【统计学习方法】学习笔记——提升方法
Static routing assignment of network reachable and telent connections
Airserver automatically receives multi screen projection or cross device projection
leetcode刷题:二叉树27(删除二叉搜索树中的节点)
【PyTorch实战】用PyTorch实现基于神经网络的图像风格迁移
随机推荐
利用栈来实现二进制转化为十进制
2022-07-07 Daily: Ian Goodfellow, the inventor of Gan, officially joined deepmind
【从 0 开始学微服务】【02】从单体应用走向服务化
[疑难杂症]pip运行突然出现ModuleNotFoundError: No module named ‘pip‘
Realize all, race, allsettled and any of the simple version of promise by yourself
2022A特种设备相关管理(锅炉压力容器压力管道)模拟考试题库模拟考试平台操作
Experiment with a web server that configures its own content
Talk about four cluster schemes of redis cache, and their advantages and disadvantages
PHP调用纯真IP数据库返回具体地址
HZOJ #240. 图形打印四
Financial data acquisition (III) when a crawler encounters a web page that needs to scroll with the mouse wheel to refresh the data (nanny level tutorial)
Error in compiling libssl
Steps of building SSM framework
[learn microservice from 0] [01] what is microservice
[statistical learning method] learning notes - support vector machine (Part 2)
leetcode刷题:二叉树25(二叉搜索树的最近公共祖先)
Creation and assignment of graphic objects
基于NeRF的三维内容生成
免费手机号码归属地API查询接口
JS to convert array to tree data