Codeforces Round #337 (Div. 2) C 找规律+构造
来源:互联网 发布:网络大电影推广方案 编辑:程序博客网 时间:2024/05/21 07:50
链接:戳这里
C. Harmony Analysis
time limit per test3 seconds
memory limit per test256 megabytes
inputstandard input
outputstandard 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.
Examples
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
题意:
+表示1,*表示-1,找出满足条件的n维坐标系下所有向量的乘积为0
思路:
写两组样例就看出来了
代码:
#include<iostream>#include<cstdio>#include<cstring>#include<algorithm>#include<string>#include<vector>#include <ctime>#include<queue>#include<set>#include<map>#include<list>#include<stack>#include<iomanip>#include<cmath>#include<bitset>#define mst(ss,b) memset((ss),(b),sizeof(ss))///#pragma comment(linker, "/STACK:102400000,102400000")typedef long long ll;typedef long double ld;#define INF (1ll<<60)-1#define Max 1e9using namespace std;int n;int p[10];char a[10][555][555];int main(){ p[0]=1;p[1]=2; a[0][1][1]='*'; a[1][1][1]=a[1][1][2]=a[1][2][1]='+';a[1][2][2]='*'; for(int k=2;k<=9;k++){ p[k]=p[k-1]*2; for(int i=1;i<=p[k-1];i++){ for(int j=1;j<=p[k-1];j++){ a[k][i][j]=a[k-1][i][j]; } } for(int i=1;i<=p[k-1];i++){ for(int j=p[k-1]+1;j<=p[k];j++){ a[k][i][j]=a[k-1][i][j-p[k-1]]; } } for(int i=p[k-1]+1;i<=p[k];i++){ for(int j=1;j<=p[k-1];j++){ a[k][i][j]=a[k-1][i-p[k-1]][j]; } } for(int i=p[k-1]+1;i<=p[k];i++){ for(int j=p[k-1]+1;j<=p[k];j++){ if(a[k-1][i-p[k-1]][j-p[k-1]]=='+') a[k][i][j]='*'; else a[k][i][j]='+'; } } } scanf("%d",&n); for(int i=1;i<=p[n];i++){ for(int j=1;j<=p[n];j++){ printf("%c",a[n][i][j]); } printf("\n"); } return 0;}
0 0
- Codeforces Round #337 (Div. 2) C 找规律+构造
- Codeforces Round #198 (Div. 2) C. Tourist Problem - 找规律
- Codeforces Round #264 (Div. 2)C(找规律)
- Codeforces Round #327 (Div. 2) (C. Median Smoothing 找规律)
- Codeforces 707 C. Pythagorean Triples(找规律)——Codeforces Round #368 (Div. 2)
- Codeforces Round #259 (Div. 2) C. Little Pony and Expected Maximum (找规律)
- Codeforces Round #182 (Div. 2)---C. Yaroslav and Sequence(不错的题,分析找规律)
- Codeforces Round #316 (Div. 2) C. Replacement 找规律 或 线段树
- Codeforces Round #372 (Div. 2) -- C. Plus and Square Root(找规律枚举)
- Codeforces Round #442 (Div. 2) C. Slava and tanks 【找规律】
- Codeforces Round #338 (Div. 2) E. Hexagons 找规律
- Codeforces Round #164(Div. 2) B. Buttons【找规律】
- Codeforces Round #446 (Div. 2) D. Gluttony 找规律
- Codeforces Round #287 (Div. 2) C. (构造)
- Codeforces Round #105 (Div. 2) C 构造
- Codeforces Round #287 (Div. 2) C 构造
- Codeforces Round #372 (Div. 2) C 构造
- Codeforces Round #313 (Div. 2)-Gerald's Hexagon 找规律-几何规律-
- Java Jvm运行机制原理
- hibernate中inverse属性用法解析
- IP地址转换为unsigned long(函数inet_addr和inet_aton)
- POJ 2739 Sum of Consecutive Prime Numbers 尺取法
- 颜色更鲜艳呀~
- Codeforces Round #337 (Div. 2) C 找规律+构造
- poj 1276 Cash Machine
- zswap
- ImageMagick简介、GraphicsMagick、命令行使用示例
- unison+inotify两台服务器间双向同步
- zzuli 1913: 小火山的计算能力(简单字符串处理 + 加减求和)
- 127.0.0.1和0.0.0.0
- Wooden Sticks Hdu 1051 贪心算法
- ZZULI-1913 小火山的计算能力 【模拟加减】