博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
cf 337 div2 c
阅读量:4968 次
发布时间:2019-06-12

本文共 3392 字,大约阅读时间需要 11 分钟。

C. Harmony Analysis
time limit per test
3 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output

The semester is already ending, so Danil made an effort and decided to visit a lesson on harmony analysis to know how does the professor look like, at least. Danil was very bored on this lesson until the teacher gave the group a simple task: find 4 vectors in 4-dimensional space, such that every coordinate of every vector is 1 or  - 1 and any two vectors are orthogonal. Just as a reminder, two vectors in n-dimensional space are considered to be orthogonal if and only if their scalar product is equal to zero, that is:

.

Danil quickly managed to come up with the solution for this problem and the teacher noticed that the problem can be solved in a more general case for 2k vectors in 2k-dimensinoal space. When Danil came home, he quickly came up with the solution for this problem. Can you cope with it?

Input

The only line of the input contains a single integer k (0 ≤ k ≤ 9).

Output

Print 2k lines consisting of 2k characters each. The j-th character of the i-th line must be equal to ' * ' if the j-th coordinate of the i-th vector is equal to  - 1, and must be equal to ' + ' if it's equal to  + 1. It's guaranteed that the answer always exists.

If there are many correct answers, print any.

Sample test(s)
input
2
output
++** +*+* ++++ +**+
Note

Consider all scalar products in example:

  • Vectors 1 and 2: ( + 1)·( + 1) + ( + 1)·( - 1) + ( - 1)·( + 1) + ( - 1)·( - 1) = 0
  • Vectors 1 and 3: ( + 1)·( + 1) + ( + 1)·( + 1) + ( - 1)·( + 1) + ( - 1)·( + 1) = 0
  • Vectors 1 and 4: ( + 1)·( + 1) + ( + 1)·( - 1) + ( - 1)·( - 1) + ( - 1)·( + 1) = 0
  • Vectors 2 and 3: ( + 1)·( + 1) + ( - 1)·( + 1) + ( + 1)·( + 1) + ( - 1)·( + 1) = 0
  • Vectors 2 and 4: ( + 1)·( + 1) + ( - 1)·( - 1) + ( + 1)·( - 1) + ( - 1)·( + 1) = 0
  • Vectors 3 and 4: ( + 1)·( + 1) + ( + 1)·( - 1) + ( + 1)·( - 1) + ( + 1)·( + 1) = 0

 

 

    假设把当前2 ^ k * (2 ^ k)分成左上,右上,左下,右下四个方阵,假设当前我们已知k - 1时的方阵,只要把左上,左下右上填成与k - 1相同方阵,右下填成

  与k - 1方阵反相即可。

 

  

1 #include 
2 #include
3 #include
4 #include
5 #include
6 7 8 using namespace std; 9 10 const int maxn = 520;11 char mar[maxn][maxn];12 int k;13 14 char invert(char x) {15 return x == '+' ? '*' : '+';16 }17 18 int main() {19 scanf("%d", &k);20 mar[0][0] = '+';21 for (int i = 1; i <= k; ++i) {22 int a = pow(2, i - 1);23 int b = pow(2, i);24 for (int r = 0; r < a; ++r) {25 for (int c = a; c < b; ++c) {26 mar[r][c] = mar[r][c - a];27 }28 }29 30 for (int r = a; r < b; ++r) {31 for (int c = 0; c < a; ++c) {32 mar[r][c] = mar[r - a][c];33 }34 }35 36 for (int r = a; r < b; ++r) {37 for (int c = a; c < b; ++c) {38 mar[r][c] = invert(mar[r][c - a]);39 }40 }41 }42 43 int a = pow(2, k);44 for (int i = 0; i < a; ++i) {45 for (int j = 0; j < a; ++j) {46 printf("%c", mar[i][j]);47 }48 printf("\n");49 }50 51 52 return 0;53 }
View Code

 

转载于:https://www.cnblogs.com/hyxsolitude/p/5117897.html

你可能感兴趣的文章
ios 上架流程
查看>>
ajax连接池和XMLHttpRequest
查看>>
[Voice communications] 声音的滤波
查看>>
BZOJ.3139.[HNOI2013]比赛(搜索 Hash)
查看>>
BZOJ.4316.小C的独立集(仙人掌 DP)
查看>>
json在线解析
查看>>
Git的优势
查看>>
《需求规格说明书》业务描述活动图
查看>>
Resnet论文翻译
查看>>
第十四天-内置函数
查看>>
连接LilyPad之Linux平台的驱动
查看>>
Apriori算法的C++实现
查看>>
SpringMVC上传图片并压缩及剪切demo
查看>>
JS字符串函数
查看>>
css案例学习之层叠样式
查看>>
require和require_once的区别
查看>>
存储设备形成的层次结构
查看>>
网站开发感悟
查看>>
香袅金猊动
查看>>
JVM调优和深入了解性能优化
查看>>