# 【Windows Of CCPC HDU - 6708】【打表，找规律】

HDU - 6708

## AC代码

#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cstdlib>
using namespace std;
const int maxn = 1024 + 10;
int T, k;
char s1[maxn][maxn], s2[maxn][maxn], s3[maxn][maxn], s4[maxn][maxn], s5[maxn][maxn], s6[maxn][maxn], s7[maxn][maxn], s8[maxn][maxn], s9[maxn][maxn], s10[maxn][maxn];
void init()
{
for(int i = 1; i <= 2; i++)
{
for(int j = 1; j <= 2; j++)
{
if(s1[i][j] == 'C')
{
//规律如下，此后的直接套用即可
for(int k = (j-1)*2+1; k <= (j-1)*2+2; k++)
s2[(i-1)*2+1][k] = 'C';
s2[(i-1)*2+2][(j-1)*2+1] = 'P', s2[(i-1)*2+2][(j-1)*2+2] = 'C';
}
else
{
for(int k = (j - 1)*2+1; k <= (j-1)*2+2; k++)
s2[(i-1)*2+1][k] = 'P';
s2[(i-1)*2+2][(j-1)*2+1] = 'C', s2[(i-1)*2+2][(j-1)*2+2] = 'P';
}
}
}
for(int i = 1; i <= 4; i++)
{
for(int j = 1; j <= 4; j++)
{
if(s2[i][j] == 'C')
{
for(int k = (j - 1)*2+1; k <= (j-1)*2+2; k++)
s3[(i-1)*2+1][k] = 'C';
s3[(i-1)*2+2][(j-1)*2+1] = 'P', s3[(i-1)*2+2][(j-1)*2+2] = 'C';
}
else
{
for(int k = (j - 1)*2+1; k <= (j-1)*2+2; k++)
s3[(i-1)*2+1][k] = 'P';
s3[(i-1)*2+2][(j-1)*2+1] = 'C', s3[(i-1)*2+2][(j-1)*2+2] = 'P';
}
}
}
for(int i = 1; i <= 8; i++)
{
for(int j = 1; j <= 8; j++)
{
if(s3[i][j] == 'C')
{
for(int k = (j - 1)*2+1; k <= (j-1)*2+2; k++)
s4[(i-1)*2+1][k] = 'C';
s4[(i-1)*2+2][(j-1)*2+1] = 'P', s4[(i-1)*2+2][(j-1)*2+2] = 'C';
}
else
{
for(int k = (j - 1)*2+1; k <= (j-1)*2+2; k++)
s4[(i-1)*2+1][k] = 'P';
s4[(i-1)*2+2][(j-1)*2+1] = 'C', s4[(i-1)*2+2][(j-1)*2+2] = 'P';
}
}
}
for(int i = 1; i <= 16; i++)
{
for(int j = 1; j <= 16; j++)
{
if(s4[i][j] == 'C')
{
for(int k = (j - 1)*2+1; k <= (j-1)*2+2; k++)
s5[(i-1)*2+1][k] = 'C';
s5[(i-1)*2+2][(j-1)*2+1] = 'P', s5[(i-1)*2+2][(j-1)*2+2] = 'C';
}
else
{
for(int k = (j - 1)*2+1; k <= (j-1)*2+2; k++)
s5[(i-1)*2+1][k] = 'P';
s5[(i-1)*2+2][(j-1)*2+1] = 'C', s5[(i-1)*2+2][(j-1)*2+2] = 'P';
}
}
}
for(int i = 1; i <= 32; i++)
{
for(int j = 1; j <= 32; j++)
{
if(s5[i][j] == 'C')
{
for(int k = (j - 1)*2+1; k <= (j-1)*2+2; k++)
s6[(i-1)*2+1][k] = 'C';
s6[(i-1)*2+2][(j-1)*2+1] = 'P', s6[(i-1)*2+2][(j-1)*2+2] = 'C';
}
else
{
for(int k = (j - 1)*2+1; k <= (j-1)*2+2; k++)
s6[(i-1)*2+1][k] = 'P';
s6[(i-1)*2+2][(j-1)*2+1] = 'C', s6[(i-1)*2+2][(j-1)*2+2] = 'P';
}
}
}
for(int i = 1; i <= 64; i++)
{
for(int j = 1; j <= 64; j++)
{
if(s6[i][j] == 'C')
{
for(int k = (j - 1)*2+1; k <= (j-1)*2+2; k++)
s7[(i-1)*2+1][k] = 'C';
s7[(i-1)*2+2][(j-1)*2+1] = 'P', s7[(i-1)*2+2][(j-1)*2+2] = 'C';
}
else
{
for(int k = (j - 1)*2+1; k <= (j-1)*2+2; k++)
s7[(i-1)*2+1][k] = 'P';
s7[(i-1)*2+2][(j-1)*2+1] = 'C', s7[(i-1)*2+2][(j-1)*2+2] = 'P';
}
}
}
for(int i = 1; i <= 128; i++)
{
for(int j = 1; j <= 128; j++)
{
if(s7[i][j] == 'C')
{
for(int k = (j - 1)*2+1; k <= (j-1)*2+2; k++)
s8[(i-1)*2+1][k] = 'C';
s8[(i-1)*2+2][(j-1)*2+1] = 'P', s8[(i-1)*2+2][(j-1)*2+2] = 'C';
}
else
{
for(int k = (j - 1)*2+1; k <= (j-1)*2+2; k++)
s8[(i-1)*2+1][k] = 'P';
s8[(i-1)*2+2][(j-1)*2+1] = 'C', s8[(i-1)*2+2][(j-1)*2+2] = 'P';
}
}
}
for(int i = 1; i <= 256; i++)
{
for(int j = 1; j <= 256; j++)
{
if(s8[i][j] == 'C')
{
for(int k = (j - 1)*2+1; k <= (j-1)*2+2; k++)
s9[(i-1)*2+1][k] = 'C';
s9[(i-1)*2+2][(j-1)*2+1] = 'P', s9[(i-1)*2+2][(j-1)*2+2] = 'C';
}
else
{
for(int k = (j - 1)*2+1; k <= (j-1)*2+2; k++)
s9[(i-1)*2+1][k] = 'P';
s9[(i-1)*2+2][(j-1)*2+1] = 'C', s9[(i-1)*2+2][(j-1)*2+2] = 'P';
}
}
}
for(int i = 1; i <= 512; i++)
{
for(int j = 1; j <= 512; j++)
{
if(s9[i][j] == 'C')
{
for(int k = (j - 1)*2+1; k <= (j-1)*2+2; k++)
s10[(i-1)*2+1][k] = 'C';
s10[(i-1)*2+2][(j-1)*2+1] = 'P', s10[(i-1)*2+2][(j-1)*2+2] = 'C';
}
else
{
for(int k = (j - 1)*2+1; k <= (j-1)*2+2; k++)
s10[(i-1)*2+1][k] = 'P';
s10[(i-1)*2+2][(j-1)*2+1] = 'C', s10[(i-1)*2+2][(j-1)*2+2] = 'P';
}
}
}
}
int main()
{
// freopen("input.txt", "r", stdin);
// freopen("output.txt", "w", stdout);
memset(s1, 'C', sizeof(s1));
cin >> T;
s1[2][1] = 'P';
init();
while(T--)
{
cin >> k;
for(int i = 1; i <= (int)(pow(2, k)); i++)
{
for(int j = 1; j <= (int)(pow(2, k)); j++)
{
if(k == 1)
cout << s1[i][j];
else if(k == 2)
cout << s2[i][j];
else if(k == 3)
cout << s3[i][j];
else if(k == 4)
cout << s4[i][j];
else if(k == 5)
cout << s5[i][j];
else if(k == 6)
cout << s6[i][j];
else if(k == 7)
cout << s7[i][j];
else if(k == 8)
cout << s8[i][j];
else if(k == 9)
cout << s9[i][j];
else if(k == 10)
cout << s10[i][j];
}
cout << endl;
}
}
}

0 条评论

• ### 【lower_bound、upperbound讲解、二分查找、最长上升子序列(LIS)模版】

注意此模板只适用于查找a中是否存在v，存在的话则返回其中一个符合条件的位置，并不一定只有那一个位置，这个视情况而定。

• ### HDU-4544 湫湫系列故事——消灭兔子 (贪心+优先队列)

将兔子的血量从大到小排列，将箭的属性写在类中（结构体也成），排序按照伤害从大到小排列，若有相等的则按价格从小到大排。

• ### 洛谷P2455 [SDOI2006]线性方程组(高斯消元)

题目描述 已知n元线性一次方程组。 ? 其中：n<=50, 系数是[b][color=red]整数<=100(有负数)，bi的值都是整数且<300（有负数）（特...

• ### 04:病毒

04:病毒 查看 提交 统计 提问 总时间限制:1000ms内存限制:65535kB描述     有一天，小y突然发现自己的计算机感染了一种病毒！还好，小y发现...

• ### 牛客NOIP提高组(三)题解

考虑算一个位置的概率，若想要$k$步把它干掉，那么与他距离为$1$到$k - 1$的点都必须阻塞

• ### 干货|十分钟教你用动态规划算法解Travelling Salesman Problem（TSP）问题，附代码……

乍一看标题，大家是不是觉得“动态规划”这四个字组合在一起有点眼熟？似乎哪会儿学过来着……但是吧，细细一琢磨，又忘了它具体是什么、怎么用、用来解决哪些问...

• ### 房上的猫：数组插入算法等难点专开

一：查找算法 public class Aini { public static void main(String[] args) { ...

• ### 【CodeForces 699B】One Bomb

枚举每个位置如果c[i]+r[j]-(本身是不是*)==总*数，则该位置即为答案。