当前位置:网站首页>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;
}
边栏推荐
- Polymorphism, final, etc
- Several ways to clear floating
- 智云健康上市:市值150亿港元 SIG经纬与京新基金是股东
- Pule frog small 5D movie equipment | 5D movie dynamic movie experience hall | VR scenic area cinema equipment
- Vxlan static centralized gateway
- 利用棧來實現二進制轉化為十進制
- [statistical learning method] learning notes - support vector machine (Part 2)
- 【统计学习方法】学习笔记——支持向量机(上)
- 2022 practice questions and mock examination of the third batch of Guangdong Provincial Safety Officer a certificate (main person in charge)
- Minimalist movie website
猜你喜欢
[爬虫]使用selenium时,躲避脚本检测
NPM instal reports agent or network problems
Four functions of opencv
leetcode刷题:二叉树27(删除二叉搜索树中的节点)
leetcode刷题:二叉树24(二叉树的最近公共祖先)
Talk about four cluster schemes of redis cache, and their advantages and disadvantages
基于NeRF的三维内容生成
Several ways to clear floating
HZOJ #240. 图形打印四
2022 practice questions and mock examination of the third batch of Guangdong Provincial Safety Officer a certificate (main person in charge)
随机推荐
【统计学习方法】学习笔记——第五章:决策树
On valuation model (II): PE index II - PE band
[crawler] avoid script detection when using selenium
智云健康上市:市值150亿港元 SIG经纬与京新基金是股东
非分区表转换成分区表以及注意事项
Steps of building SSM framework
Master公式。(用于计算递归的时间复杂度。)
密码学系列之:在线证书状态协议OCSP详解
Guangzhou held work safety conference
Leetcode skimming: binary tree 21 (verifying binary search tree)
OSPF exercise Report
How to use PS link layer and shortcut keys, and how to do PS layer link
Connect to blog method, overload, recursion
BGP actual network configuration
2022A特种设备相关管理(锅炉压力容器压力管道)模拟考试题库模拟考试平台操作
leetcode刷题:二叉树25(二叉搜索树的最近公共祖先)
Four functions of opencv
ACL 2022 | small sample ner of sequence annotation: dual tower Bert model integrating tag semantics
visual stdio 2017关于opencv4.1的环境配置
[pytorch practice] use pytorch to realize image style migration based on neural network