当前位置:网站首页>HZOJ #240. 图形打印四
HZOJ #240. 图形打印四
2022-07-07 10:36:00 【段舸】
题目:240. 图形打印四
题目传送门:240题
样例输入
1
2
3
4
-1
样例输出
X
-
X X
X
X X
-
X X X X
X X
X X X X
X X
X
X X
X X X X
X X
X X X X
-
X X X X X X X X
X X X X
X X X X X X X X
X X X X
X X
X X X X
X X X X X X X X
X X X X
X X X X X X X X
X X X X
X X
X X X X
X X
X
X X
X X X X
X X
X X X X
X X X X X X X X
X X X X
X X X X X X X X
X X X X
X X
X X X X
X X X X X X X X
X X X X
X X X X X X X X
-
数据规模与约定
时间限制:1 s
内存限制:256 M
100% 的数据保证 1≤n≤7
代码
#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;
}
边栏推荐
- leetcode刷题:二叉树24(二叉树的最近公共祖先)
- Tutorial on the principle and application of database system (008) -- exercises on database related concepts
- Ctfhub -web SSRF summary (excluding fastcgi and redI) super detailed
- Will the filing free server affect the ranking and weight of the website?
- Tutorial on the principle and application of database system (011) -- relational database
- Epp+dis learning road (2) -- blink! twinkle!
- 2022危险化学品生产单位安全生产管理人员考题及在线模拟考试
- 用mysql查询某字段是否有索引
- SQL injection -- Audit of PHP source code (take SQL lab 1~15 as an example) (super detailed)
- Customize the web service configuration file
猜你喜欢
SQL head injection -- injection principle and essence
ICLR 2022 | 基于对抗自注意力机制的预训练语言模型
The left-hand side of an assignment expression may not be an optional property access.ts(2779)
Visual stdio 2017 about the environment configuration of opencv4.1
The hoisting of the upper cylinder of the steel containment of the world's first reactor "linglong-1" reactor building was successful
Epp+dis learning road (2) -- blink! twinkle!
如何将 @Transactional 事务注解运用到炉火纯青?
[statistical learning method] learning notes - logistic regression and maximum entropy model
Preorder, inorder and postorder traversal of binary tree
leetcode刷题:二叉树23(二叉搜索树中的众数)
随机推荐
GCC compilation error
[爬虫]使用selenium时,躲避脚本检测
ip2long之后有什么好处?
ICLR 2022 | 基于对抗自注意力机制的预训练语言模型
The hoisting of the upper cylinder of the steel containment of the world's first reactor "linglong-1" reactor building was successful
About web content security policy directive some test cases specified through meta elements
SQL Lab (36~40) includes stack injection, MySQL_ real_ escape_ The difference between string and addslashes (continuous update after)
【统计学习方法】学习笔记——逻辑斯谛回归和最大熵模型
[Q&A]AttributeError: module ‘signal‘ has no attribute ‘SIGALRM‘
Visual stdio 2017 about the environment configuration of opencv4.1
sql-lab (54-65)
test
Using stack to convert binary to decimal
Simple implementation of call, bind and apply
【PyTorch实战】用PyTorch实现基于神经网络的图像风格迁移
Solve server returns invalid timezone Go to ‘Advanced’ tab and set ‘serverTimezone’ property manually
leetcode刷题:二叉树25(二叉搜索树的最近公共祖先)
MPLS experiment
[pytorch practice] write poetry with RNN
Solutions to cross domain problems