HU-6778 Windows Of CCPC(表を打って再帰する)
http://acm.hdu.edu.cn/showproblem.php?pid=6708
Time Limit:2000/1000 MS(Java/Others) メモリLimit:65536/65536 K(Java/Others)
Problem Description
In recent years,CCPC has developed rapidly and gained a large number of comppetitors.One contestant designed a design caled CCPC Windows.The 1-st order PC window is show ingthe figre:
And the 2-nd order CCPC window is shown in the figre:
We can easure find that the window of CCPC of order k is generated by taring the window of CCPC of order k−1 as C of order k,and the relt of inverting C/P in the window of CCPC of order k−1 as P オブライダー k.
And now I have an order k ,please output k-order CCPC Windows、The CCPC window of order k is a 2 k∗2 k matrix.
Input
The input file contains
T test samples.(1<=T<=10)The first line of input file is an integer T.Then the T LINE contains a positive integers k、(1≦k≦10)
Output
For each test case,you shoult out put the answer.
Sample Input
ソurce
2019中国大学生プログラム設計コンテスト(CCPC)-ネット選抜試合
この問題がややこしいのは改行符の処理です.メーターと再帰でできるような気がします.
再帰する
問題解決の考え方:
最初は4文字で、左下は他の3つと違っています.
最初の2つを使って、2つ目を4つの部分に分けて、左下と1つ目の反対、つまりPをCに変えて、CをPにして、残りは同じです.
全部で2^n行を出力します.一行の出力ができます.もし私が8行を出力したいなら、今は1行目を出力します.
では、総出力4行目の1行目は2回出力されます.
左下の角の部分を出力すると、これは総挙動4行の該当行が逆に1回出力され、1回出力されるのと同じです.
STLメーター
行数によって法則を探すこともできます.
表G[2^10+1]、[2^10+1]を前倒しして出力する場合は、2つのfor 1->2^kでいいです.暇があれば試してみてもいいです.
転載先:https://www.cnblogs.com/jiamian/p/11403395.html
Time Limit:2000/1000 MS(Java/Others) メモリLimit:65536/65536 K(Java/Others)
Problem Description
In recent years,CCPC has developed rapidly and gained a large number of comppetitors.One contestant designed a design caled CCPC Windows.The 1-st order PC window is show ingthe figre:
And the 2-nd order CCPC window is shown in the figre:
We can easure find that the window of CCPC of order k is generated by taring the window of CCPC of order k−1 as C of order k,and the relt of inverting C/P in the window of CCPC of order k−1 as P オブライダー k.
And now I have an order k ,please output k-order CCPC Windows、The CCPC window of order k is a 2 k∗2 k matrix.
Input
The input file contains
T test samples.(1<=T<=10)The first line of input file is an integer T.Then the T LINE contains a positive integers k、(1≦k≦10)
Output
For each test case,you shoult out put the answer.
Sample Input
3
1
2
3
Sample OutputCC
PC
CCCC
PCPC
PPCC
CPPC
CCCCCCCC
PCPCPCPC
PPCCPPCC
CPPCCPPC
PPPPCCCC
CPCPPCPC
CCPPPPCC
PCCPCPPC
ソurce
2019中国大学生プログラム設計コンテスト(CCPC)-ネット選抜試合
この問題がややこしいのは改行符の処理です.メーターと再帰でできるような気がします.
再帰する
問題解決の考え方:
最初は4文字で、左下は他の3つと違っています.
最初の2つを使って、2つ目を4つの部分に分けて、左下と1つ目の反対、つまりPをCに変えて、CをPにして、残りは同じです.
全部で2^n行を出力します.一行の出力ができます.もし私が8行を出力したいなら、今は1行目を出力します.
では、総出力4行目の1行目は2回出力されます.
左下の角の部分を出力すると、これは総挙動4行の該当行が逆に1回出力され、1回出力されるのと同じです.
1 #include
2 #include <string.h>
3 #include
4 #include <string>
5 #include
6 #include
7 #include
8 #include
9 #include <set>
10 #include
STLメーター
1 #include
2 #include <string.h>
3 #include
4 #include <string>
5 #include
6 #include
7 #include
8 #include
9 #include <set>
10 #include
行数によって法則を探すこともできます.
表G[2^10+1]、[2^10+1]を前倒しして出力する場合は、2つのfor 1->2^kでいいです.暇があれば試してみてもいいです.
転載先:https://www.cnblogs.com/jiamian/p/11403395.html