`
阿尔萨斯
  • 浏览: 4164723 次
社区版块
存档分类
最新评论

Codeforces 384A Coder(水题)

 
阅读更多

题目链接: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;
}


分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics