亚洲免费在线-亚洲免费在线播放-亚洲免费在线观看-亚洲免费在线观看视频-亚洲免费在线看-亚洲免费在线视频

cf 323A A. Black-and-White Cube 立體構(gòu)造

系統(tǒng) 1930 0
A. Black-and-White Cube
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output

You are given a cube of size k × k × k , which consists of unit cubes. Two unit cubes are considered neighbouring, if they have common face.

Your task is to paint each of k 3 unit cubes one of two colours (black or white), so that the following conditions must be satisfied:

  • each white cube has exactly 2 neighbouring cubes of white color;
  • each black cube has exactly 2 neighbouring cubes of black color.
Input

The first line contains integer k (1 ≤ k ≤ 100) , which is size of the cube.

Output

Print -1 if there is no solution. Otherwise, print the required painting of the cube consequently by layers. Print a k × k matrix in the first k lines, showing how the first layer of the cube should be painted. In the following k lines print a k × k matrix — the way the second layer should be painted. And so on to the last k -th layer. Note that orientation of the cube in the space does not matter.

Mark a white unit cube with symbol " w " and a black one with " b ". Use the format of output data, given in the test samples. You may print extra empty lines, they will be ignored.

Sample test(s)
Input
              1


            
Output
              -1


            
Input
              2


            
Output
              bb

ww



bb

ww


            

題目意思,輸出一個k*k*k的立體模型,使每個b的旁邊有2個b,每個k的旁邊有2個k
題解:

題目說的輸出描述有點問題,它說的是先輸出你的第1層,再輸出k層從1到k的你的模型。實際上只用輸出你構(gòu)造的模型的1-k層。

這里提供兩種構(gòu)造方法
第1種
bbwwbb
bbwwbb
wwbbww
wwbbww
bbwwbb
bbwwbb
這種就是4個4個的。。以后每層就把上一層取反就OK了
還有一種是
bbbbbb
bwwwwb
bwbbwb
bwbbwb
bwwwwb
bbbbbb
類似這種不斷將最外層圍起來的構(gòu)造方式,同理,以后的每層就把上一層取反就OK了。。
構(gòu)造方法不唯一的。


至于 k 為奇數(shù)時無解我無法證明這個。。。


?

    /*

 * @author ipqhjjybj

 * @date  20130709

 *

 */

#include <cstdio>

#include <cstdlib>



int main(){

    int k;

    scanf("%d",&k);

    if(k&1) {

        puts("-1");

        return 0;

    }

    for(int i=0;i<k;i++){

        for(int j=0;j<k;j++){

            for(int z=0;z<k;z++){

               putchar(((j>>1)&1)^((z>>1)&1)^(i&1)?'w':'b');

            }

            putchar('\n');

        }

        putchar('\n');

    }

    return 0;

}


  


?

?

cf 323A A. Black-and-White Cube 立體構(gòu)造


更多文章、技術(shù)交流、商務(wù)合作、聯(lián)系博主

微信掃碼或搜索:z360901061

微信掃一掃加我為好友

QQ號聯(lián)系: 360901061

您的支持是博主寫作最大的動力,如果您喜歡我的文章,感覺我的文章對您有幫助,請用微信掃描下面二維碼支持博主2元、5元、10元、20元等您想捐的金額吧,狠狠點擊下面給點支持吧,站長非常感激您!手機(jī)微信長按不能支付解決辦法:請將微信支付二維碼保存到相冊,切換到微信,然后點擊微信右上角掃一掃功能,選擇支付二維碼完成支付。

【本文對您有幫助就好】

您的支持是博主寫作最大的動力,如果您喜歡我的文章,感覺我的文章對您有幫助,請用微信掃描上面二維碼支持博主2元、5元、10元、自定義金額等您想捐的金額吧,站長會非常 感謝您的哦!!!

發(fā)表我的評論
最新評論 總共0條評論
主站蜘蛛池模板: 天天骑天天射 | 日韩精品久久久毛片一区二区 | 毛片免费观看成人 | 夜色私人影院永久入口 | 伊人久久狼人 | a级亚洲片精品久久久久久久 | 欧美交换乱理伦片120秒 | 精品国产精品a | 国产99精品在线观看 | 9999人体做爰大胆 | 久久精品国内一区二区三区 | 日韩伦理亚洲欧美在线一区 | 5g国产精品影院天天5g天天爽 | 亚洲国产欧美精品 | 久久久久一级片 | 四虎影院精品在线观看 | 亚洲综合色秘密影院秘密影院 | 6080一级毛片 | 国产精品色婷婷在线观看 | 国产黄网永久免费 | 亚洲a毛片| 国产成人亚洲日本精品 | www.奇米第四色 | 中文字幕在线视频观看 | 99久久国产综合精品2020 | 婷婷玖玖| 国产99在线播放 | 国产精品免费一区二区三区四区 | 一级特黄一欧美俄罗斯毛片 | 亚洲欧美日韩综合 | 久久一区二区三区免费播放 | 欧美成人午夜视频免看 | 久久精品99久久香蕉国产色戒 | 国产美女亚洲精品久久久毛片 | 免费国产福利 | 国产激情久久久久影院小草 | 国产精品久久一区二区三区 | 99精品国产兔费观看久久99 | 在线a亚洲视频播放在线观看 | 国产精品嫩草研究所永久网址 | 亚洲成人黄色 |