cf 337 div2 c
3 seconds
256 megabytes
standard input
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?
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
假设把当前2 ^ k * (2 ^ k)分成左上,右上,左下,右下四个方阵,假设当前我们已知k - 1时的方阵,只要把左上,左下右上填成与k - 1相同方阵,右下填成
与k - 1方阵反相即可。
- #include <iostream>
- #include <cstdio>
- #include <cstring>
- #include <algorithm>
- #include <cmath>
- using namespace std;
- const int maxn = ;
- char mar[maxn][maxn];
- int k;
- char invert(char x) {
- return x == '+' ? '*' : '+';
- }
- int main() {
- scanf("%d", &k);
- mar[][] = '+';
- for (int i = ; i <= k; ++i) {
- int a = pow(, i - );
- int b = pow(, i);
- for (int r = ; r < a; ++r) {
- for (int c = a; c < b; ++c) {
- mar[r][c] = mar[r][c - a];
- }
- }
- for (int r = a; r < b; ++r) {
- for (int c = ; c < a; ++c) {
- mar[r][c] = mar[r - a][c];
- }
- }
- for (int r = a; r < b; ++r) {
- for (int c = a; c < b; ++c) {
- mar[r][c] = invert(mar[r][c - a]);
- }
- }
- }
- int a = pow(, k);
- for (int i = ; i < a; ++i) {
- for (int j = ; j < a; ++j) {
- printf("%c", mar[i][j]);
- }
- printf("\n");
- }
- return ;
- }
cf 337 div2 c的更多相关文章
- cf 442 div2 F. Ann and Books(莫队算法)
cf 442 div2 F. Ann and Books(莫队算法) 题意: \(给出n和k,和a_i,sum_i表示前i个数的和,有q个查询[l,r]\) 每次查询区间\([l,r]内有多少对(i, ...
- CF#603 Div2
差不多半年没打cf,还是一样的菜:不过也没什么,当时是激情,现在已是兴趣了,开心就好. A Sweet Problem 思维,公式推一下过了 B PIN Codes 队友字符串取余过了,结果今天早上一 ...
- CF R631 div2 1330 E Drazil Likes Heap
LINK:Drazil Likes Heap 那天打CF的时候 开场A读不懂题 B码了30min才过(当时我怀疑B我写的过于繁琐了. C比B简单多了 随便yy了一个构造发现是对的.D也超级简单 dp了 ...
- CF#581 (div2)题解
CF#581 题解 A BowWow and the Timetable 如果不是4幂次方直接看位数除以二向上取整,否则再减一 #include<iostream> #include< ...
- [CF#286 Div2 D]Mr. Kitayuta's Technology(结论题)
题目:http://codeforces.com/contest/505/problem/D 题目大意:就是给你一个n个点的图,然后你要在图中加入尽量少的有向边,满足所有要求(x,y),即从x可以走到 ...
- CF 197 DIV2 Xenia and Bit Operations 线段树
线段树!!1A 代码如下: #include<iostream> #include<cstdio> #define lson i<<1 #define rson i ...
- CF#345 div2 A\B\C题
A题: 贪心水题,注意1,1这组数据,坑了不少人 #include <iostream> #include <cstring> using namespace std; int ...
- CF R303 div2 C. Woodcutters
C. Woodcutters time limit per test 1 second memory limit per test 256 megabytes input standard input ...
- CF 192 Div2
A.Cakeminator 暴搞之,从没有草莓覆盖的行.列遍历 char map[30][30]; int vis[30][30]; int hang[30],lie[30]; int main() ...
随机推荐
- android传感器;摇一摇抽签功能
package com.kane.sensortest; import java.util.Random; import android.hardware.Sensor; import android ...
- 写给小白的JVM学习指南
Java 虚拟机是学习 Java 的基础,也是迈入高级 Java 开发工程师的必备知识点.所以今天这篇文章我们来聊聊如何从零开始学习 Java 虚拟机. 基础 对于刚刚接触 JVM 的同学来说,JVM ...
- Powershell远程在Azure A7虚拟机执行Java JVM失败
近期.使用Powershell脚本在A7 (8核,56G内存)配置的 Azure VM(Virtual Machine.虚拟机)上远程运行Java JVM时 (java.exe -version).总 ...
- 一次c3p0连接池连接异常错误的排查
近期写了一个数据库採集程序,大概过程是将SQLSERVER数据库的数据定时採集到Oracle数据库. 1小时出一次数据,每次数据量在2W左右.环境採用Sping3+hibernate4,数据库连接池採 ...
- MySQL 登录问题
1.问题一:使用update mysql.user set password='root'改动密码后,不能登录 解决:操作过程例如以下. (1)关闭mysql(杀掉mysqld进程),然后使用命令: ...
- 【Hnoi2013】Bzoj3143 游走
Position: http://www.lydsy.com/JudgeOnline/problem.php?id=3143 List Bzoj3143 Hnoi2013 游走 List Descri ...
- bzoj1106
模拟+树状数组 先开始以为是先删距离最小的,这样可以减小上下的距离,然后觉得很难写,看码长很短,就看了题解,结果很奥妙 我们只考虑两种元素,就是如果像-a-b-a-b-这样的肯定得交换,如果像-a-b ...
- 虚拟化技术概要之VMM结构
1. 概述 当前主流的 VMM (Virtual Machine Monitor) 实现结构可以分为三类: 宿主模型 (OS-hosted VMMs)Hypervisor 模型 (Hypervisor ...
- bzoj1433[ZJOI2009]假期的宿舍(匈牙利)
1433: [ZJOI2009]假期的宿舍 Time Limit: 10 Sec Memory Limit: 162 MBSubmit: 2544 Solved: 1074 [Submit][St ...
- [App Store Connect帮助]一、 App Store Connect 使用入门(3)首页概述
从首页可以访问 App Store Connect 的各个部分.您仅能访问每个部分中与您的用户职能相关联的功能. [提示]通过点按任何页面顶部的“App Store Connect”,您可以随时返回 ...