Codeforces Round #337 (Div. 2) 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: 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?
The only line of the input contains a single integer k (0 ≤ k ≤ 9).
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.
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
题意:给 k,构造2^k * 2^k的图, 使得任意两行 相乘相加值为0
题解:对于一个 满足了条件的 正方形,想要得到将其边长翻倍的图形 我们将它复制接右边,接到正下方,再取反接到斜对角,就是了;
根据这个我们从1*1得到 2*2得到 4*4---到答案
//meek///#include<bits/stdc++.h>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <algorithm>
#include<iostream>
#include<bitset>
#include<vector>
#include <queue>
#include <map>
#include <set>
#include <stack>
using namespace std ;
#define mem(a) memset(a,0,sizeof(a))
#define pb push_back
#define fi first
#define se second
#define MP make_pair
typedef long long ll; const int N = ;
const int M = ;
const int inf = 0x3f3f3f3f;
const int MOD = ;
const double eps = 0.000001; int a[N][N],n;
int main() {
scanf("%d",&n);
a[][]=;
for(int x=;x<=n;x++) {
for(int i=;i<(<<x-);i++) {
for(int j=;j<(<<x-);j++) {
a[i][j+(<<x-)]=a[i][j];
a[i+(<<x-)][j]=a[i][j];
a[i+(<<x-)][j+(<<x-)]=-a[i][j];
}
}
}
for(int i=;i<(<<n);i++) {
for(int j=;j<(<<n);j++) {
if(a[i][j])printf("+");
else printf("*");
}
printf("\n");
}
return ;
}
代码
Codeforces Round #337 (Div. 2) C. Harmony Analysis 数学的更多相关文章
- Codeforces Round #337 (Div. 2) C. Harmony Analysis 构造
C. Harmony Analysis 题目连接: http://www.codeforces.com/contest/610/problem/C Description The semester i ...
- Codeforces Round #337 (Div. 2) 610C Harmony Analysis(脑洞)
C. Harmony Analysis time limit per test 3 seconds memory limit per test 256 megabytes input standard ...
- Codeforces Round #337 (Div. 2) C. Harmony Analysis
题目链接:http://codeforces.com/contest/610/problem/C 解题思路: 将后一个矩阵拆分为四个前一状态矩阵,其中三个与前一状态相同,剩下一个直接取反就行.还有很多 ...
- Codeforces Round #337 (Div. 2)
水 A - Pasha and Stick #include <bits/stdc++.h> using namespace std; typedef long long ll; cons ...
- Codeforces Round #337 (Div. 2) D. Vika and Segments 线段树扫描线
D. Vika and Segments 题目连接: http://www.codeforces.com/contest/610/problem/D Description Vika has an i ...
- Codeforces Round #337 (Div. 2) B. Vika and Squares 贪心
B. Vika and Squares 题目连接: http://www.codeforces.com/contest/610/problem/B Description Vika has n jar ...
- Codeforces Round #337 (Div. 2) A. Pasha and Stick 数学
A. Pasha and Stick 题目连接: http://www.codeforces.com/contest/610/problem/A Description Pasha has a woo ...
- Codeforces Round #337 (Div. 2) D. Vika and Segments (线段树+扫描线+离散化)
题目链接:http://codeforces.com/contest/610/problem/D 就是给你宽度为1的n个线段,然你求总共有多少单位的长度. 相当于用线段树求面积并,只不过宽为1,注意y ...
- Codeforces Round #337 (Div. 2) D. Vika and Segments 线段树 矩阵面积并
D. Vika and Segments Vika has an infinite sheet of squared paper. Initially all squares are whit ...
随机推荐
- struts2传递参数值的3中方式
在使用struts2的时候,当要传递的参数不多的时候,我们会选择使用属性来传参,而当要传递的参数很多的时候,或者多个action会有共用的参数时,我们会使用另外两种传参方式. 注意:使用Model D ...
- iOS代码实践总结
转载地址:http://mobile.51cto.com/hot-492236.htm 最近一个月除了专门抽时间和精力重构之外,还有就是遇到需要添加功能的模块的时候,由于项目中的代码历史因素比较多,第 ...
- mysql字段累加concat
update tablename set field1=concat(field1,'_bak') where field2 like '%@xxx’
- mysql取整,小数点处理函数floor(), round()
mysql数值处理函数floor与round 在mysql中,当处理数值时,会用到数值处理函数,如有一个float型数值2.13,你想只要整数2,那就需要下面的函数floor与round. ...
- 【ASP.NET MVC 回顾】HtmlHepler应用-分页组件
以前在ASP.NET WebForm开发中会用到许多控件,像DropDownList等.同样ASP.NET MVC中也有类似的控件-HtmlHelper. HtmlHelper和服务器控件相比,Htm ...
- [转]gdb结合coredump定位崩溃进程
[转]gdb结合coredump定位崩溃进程 http://blog.sina.com.cn/s/blog_54f82cc201013tk4.html Linux环境下经常遇到某个进程挂掉而找不到原因 ...
- sharepoint 2010 重建遇到的问题
需要重新安装Sharepoint 2010 ,遇到问题记录下来,sharepoint中安装了热补丁和英文语言包. 卸载: 1.运行配置向导将服务器从服务场中脱离: 2.在管理中心中卸载sharepoi ...
- [shell实例]——用脚本实现向多台服务器批量复制文件(nmap、scp)
练习环境: (1)所有服务器将防火墙和selinux关闭 (2)所有服务器的root密码设置为aixocm (3)所有服务器都为10.0.100.*网段,并保证能够和其它主机通信 (4)所有服务器确保 ...
- 20145105 《Java程序设计》第2周学习总结
20145105 <Java程序设计>第2周学习总结 教材学习内容总结 第三章主要的学习内容与c语言有很多相似的地方,讲述了Java的基本语法.其中涵盖: 1. 类型: - short整数 ...
- 转载:js动态获取图片长宽尺寸(兼容所有浏览器,速度极快)
转自:http://blog.phpdr.net/js-get-image-size.html lightbox类效果为了让图片居中显示而使用预加载,需要等待完全加载完毕才能显示,体验不佳(如fili ...