Codeforces 384A Coder(水题)

来源:互联网 发布:剑灵灵族女萌萌的数据 编辑:程序博客网 时间:2024/06/18 11:16

题目链接:Codeforces 384A Coder


题目大意:给出n,在一个n * n的棋盘,要求在这个棋盘上方尽量多的棋子,棋子不能相邻,给出摆法。


解题思路:错开摆就行了,水题。


#include <stdio.h>#include <string.h>#include <algorithm>using namespace std;int main () {int n;scanf("%d", &n);printf("%d\n", (n * n + 1) / 2);for (int i = 0; i < n; i++) {for (int j = 0; j < n; j++) printf("%c", (i + j) % 2 ? '.' : 'C');printf("\n");}return 0;}


0 0
原创粉丝点击