当前位置:网站首页>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;
}
边栏推荐
- Pule frog small 5D movie equipment | 5D movie dynamic movie experience hall | VR scenic area cinema equipment
- 有什么类方法或是函数可以查看某个项目的Laravel版本的?
- Using stack to convert binary to decimal
- [statistical learning method] learning notes - support vector machine (Part 2)
- Airserver automatically receives multi screen projection or cross device projection
- 【统计学习方法】学习笔记——提升方法
- Day-24 UDP, regular expression
- [pytorch practice] write poetry with RNN
- Cookie
- Sorting, dichotomy
猜你喜欢

【统计学习方法】学习笔记——提升方法

How to use PS link layer and shortcut keys, and how to do PS layer link

Day-16 set
![Routing strategy of multi-point republication [Huawei]](/img/5c/2e3b739ce7199f0d2a4ddd7c3856fc.jpg)
Routing strategy of multi-point republication [Huawei]

Leetcode skimming: binary tree 23 (mode in binary search tree)

BGP actual network configuration

Pule frog small 5D movie equipment | 5D movie dynamic movie experience hall | VR scenic area cinema equipment

leetcode刷题:二叉树23(二叉搜索树中的众数)

visual stdio 2017关于opencv4.1的环境配置

处理链中断后如何继续/子链出错removed from scheduling
随机推荐
HZOJ #235. 递归实现指数型枚举
爱可可AI前沿推介(7.7)
[Q&A]AttributeError: module ‘signal‘ has no attribute ‘SIGALRM‘
How to use PS link layer and shortcut keys, and how to do PS layer link
Image pixel read / write operation
Day-16 set
What if does not match your user account appears when submitting the code?
Cryptography series: detailed explanation of online certificate status protocol OCSP
Leetcode skimming: binary tree 22 (minimum absolute difference of binary search tree)
Layer pop-up layer closing problem
visual stdio 2017关于opencv4.1的环境配置
MySQL导入SQL文件及常用命令
How to apply @transactional transaction annotation to perfection?
ip2long与long2IP 分析
Charles: four ways to modify the input parameters or return results of the interface
leetcode刷题:二叉树26(二叉搜索树中的插入操作)
.Net下极限生产力之efcore分表分库全自动化迁移CodeFirst
leetcode刷题:二叉树25(二叉搜索树的最近公共祖先)
[learn microservices from 0] [03] explore the microservice architecture
Error in compiling libssl