Codeforces 610C:Harmony Analysis(构造)
【题目链接】 http://codeforces.com/problemset/problem/610/C
【题目大意】
构造出2^n个由1和-1组成的串使得其两两点积为0
【题解】
我们可以构造这样一个矩阵,右下角四分之一和其余三个分块相反,
不断扩展这个矩阵即可。
【代码】
#include <cstdio>
#define rep(i,n) for(int i=1;i<=n;i++)
using namespace std;
const int N=1000;
int k,p[N][N];
int main(){
for(int n=1;n<=9;n++){
int m=1<<(n-1);
rep(i,m)rep(j,m)p[i+m][j]=p[i][j+m]=p[i][j],p[i+m][j+m]=!p[i][j];
}while(~scanf("%d",&k)){rep(i,1<<k){rep(j,1<<k)putchar(p[i][j]?'+':'*');puts("");}}
return 0;
}
Codeforces 610C:Harmony Analysis(构造)的更多相关文章
- CodeForces 610C Harmony Analysis
构造 #include<cstdio> #include<cstring> #include<cmath> #include<algorithm> us ...
- 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 ...
- 【53.57%】【codeforces 610C】Harmony Analysis
time limit per test3 seconds memory limit per test256 megabytes inputstandard input outputstandard o ...
- Codeforces Round #337 (Div. 2) C. Harmony Analysis 数学
C. Harmony Analysis The semester is already ending, so Danil made an effort and decided to visit a ...
- Codeforces Round #337 (Div. 2) C. Harmony Analysis
题目链接:http://codeforces.com/contest/610/problem/C 解题思路: 将后一个矩阵拆分为四个前一状态矩阵,其中三个与前一状态相同,剩下一个直接取反就行.还有很多 ...
- Codeforces 1383D - Rearrange(构造)
Codeforces 题面传送门 & 洛谷题面传送门 一道不算困难的构造,花了一节英语课把它搞出来了,题解简单写写吧( 考虑从大往小加数,显然第三个条件可以被翻译为,每次加入一个元素,如果它所 ...
- Codeforces 549B. Looksery Party[构造]
B. Looksery Party time limit per test 1 second memory limit per test 256 megabytes input standard in ...
- codeforces 323A. Black-and-White Cube 构造
输入n 1 <= n <= 100 有一个n * n * n 的立方体,由n ^ 3 个1 * 1 * 1 的单位立方体构成 要用white 和 black 2种颜色来染这n ^ 3个立方 ...
随机推荐
- 2017ACM暑期多校联合训练 - Team 1 1002 HDU 6034 Balala Power! (字符串处理)
题目链接 Problem Description Talented Mr.Tang has n strings consisting of only lower case characters. He ...
- MSSQL 错误:在将 varchar 值 '1,2,3,5,6' 转换成数据类型 int 时失败。
MSSQL 错误:在将 varchar 值 '1,2,3,5,6' 转换成数据类型 int 时失败.
- 对象方法、类方法、原型方法 && 私有属性、公有属性、公有静态属性
<html> <head> <meta http-equiv="Content-Type" content="text/html; char ...
- TensorFlow两种方式计算Cross Entropy
sparse_softmax_cross_entropy_with_logits与softmax_cross_entropy_with_logits import tensorflow as tf y ...
- php伪协议
文件包含函数:include.require.include_once.require_once.highlight_file .show_source .readfile .file_get_con ...
- [Leetcode Week15] Add Two Numbers
Add Two Numbers 题解 原创文章,拒绝转载 题目来源:https://leetcode.com/problems/add-two-numbers/description/ Descrip ...
- 51/52单片机 TCON控制字及TMOD寄存器
转载:http://blog.csdn.net/u010698858/article/details/44118157 TCON:定时器控制寄存器 寄存器地址88H,位寻址8FH-88H. 位地址 8 ...
- 15:django 缓存架构
动态网站的一个基本权衡就是他们是动态的,每次一个用户请求一个页面,web服务器进行各种各样的计算-从数据库查询到模板渲染到业务逻辑-从而生成站点访问者看到的页面.从处理开销的角度来看,相比标准的从文件 ...
- Centos7 环境准备
Centos7 环境准备 #关闭防火墙 systemctl stop firewalld systemctl disable firewalld #关闭selinux sed -i 's/SELINU ...
- ZOJ-3319
Islands Time Limit: 1 Second Memory Limit: 32768 KB There are N islands and some directed paths ...