Codeforces 610С — Harmony Analysis 找规律
来源:互联网 发布:程序员之路 编辑:程序博客网 时间:2024/04/30 04:53
C. Harmony Analysis
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: find4 vectors in 4-dimensional space, such that every coordinate of every vector is1 or - 1 and any two vectors are orthogonal. Just as a reminder, two vectors inn-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 for2k vectors in2k-dimensinoal space. When Danil came home, he quickly came up with the solution for this problem. Can you cope with it?
The only line of the input contains a single integer k (0 ≤ k ≤ 9).
Print 2k lines consisting of2k characters each. Thej-th character of the i-th line must be equal to ' * ' if thej-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.
2
++**+*+*+++++**+
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
++ ++
+* +*
++ **
+* *+
可以看出左上,右上和左下三部分是相同的,右下部分是和其他三部分相反的。
#include<bits/stdc++.h>#define LL long longusing namespace std;int a[1025][1025];int main(){ int n; cin>>n; int t=1; a[0][0]=1; while(n--){ for(int i=0;i<t;i++){ for(int j=0;j<t;j++){ a[i+t][j]=a[i][j+t]=a[i][j]; a[i+t][j+t]=-a[i][j]; } } t<<=1; } for(int i=0;i<t;i++){ for(int j=0;j<t;j++){ if(a[i][j]==1)putchar('+'); else putchar('*'); } printf("\n"); } return 0;}
- Codeforces 610С — Harmony Analysis 找规律
- Codeforces - 337C(div2) - Harmony Analysis(找规律)
- CodeForces 610 B - Harmony Analysis
- Codeforces 610C:Harmony Analysis 递归
- codeforces 610C Harmony Analysis 构造
- CodeForces 610 C. Harmony Analysis(构造)
- Codeforces 610C Harmony Analysis(构造)
- 【53.57%】【codeforces 610C】Harmony Analysis
- Harmony Analysis CodeForces
- 610C Harmony Analysis
- Codeforces Round #337 (Div. 2) 610C Harmony Analysis(脑洞)
- Codeforces 610C Harmony Analysis 【神奇的题目】
- Codeforces Round #337 (Div. 2) C Harmony Analysis
- *Codeforces Round #337 (Div. 2) C Harmony Analysis 构造题
- Codeforces Round #337 (Div. 2) C Harmony Analysis
- Codeforces Round #337 (Div. 2) C. Harmony Analysis (构造)
- Codeforces Round #337 (Div. 2)C. Harmony Analysis
- Codeforces #337 (Div.2)C.Harmony Analysis【构造】
- The Maximum-Subarray Problem
- [天文与科学]黄金眼
- iOS SEL(@selector)原理
- PHP定时执行任务的实现
- GNU自动化工具链autotools
- Codeforces 610С — Harmony Analysis 找规律
- js获取 type=radio 值的方法
- C语言中格式转换问题
- shell提取字符串指定的内容
- linux网络命令--3--ping -- traceroute -- arp
- 教你透彻了解红黑树---第一篇
- Java之泛型
- openstack 安装手册
- 开发错误总结