CodeForces 384A Coder
Time Limit:1000MS Memory Limit:262144KB 64bit IO Format:%I64d & %I64u
Description
Iahub likes chess very much. He even invented a new chess piece named Coder. A Coder can move (and attack) one square horizontally or vertically. More precisely, if the Coder is located at position (x, y), he can move to (or attack) positions (x + 1, y), (x–1, y), (x, y + 1)and (x, y–1).
Iahub wants to know how many Coders can be placed on an n × n chessboard, so that no Coder attacks any other Coder.
Input
The first line contains an integer n(1 ≤ n ≤ 1000).
Output
On the first line print an integer, the maximum number of Coders that can be placed on the chessboard.
On each of the next n lines print n characters, describing the configuration of the Coders. For an empty cell print an '.', and for a Coder print a 'C'.
If there are multiple correct answers, you can print any.
Sample Input
2
2
C.
.C
#include <stdio.h>
#include <string.h>
int main()
{
int n;
int i,j,k;
while(scanf("%d",&n)!=EOF)
{
if(n%==)
{
printf("%d\n",n*n/);
for(i=;i<=n/;i++)
{
for(j=;j<=n;j++)
if(j%==)
printf("C");
else
printf(".");
printf("\n");
for(j=;j<=n;j++)
if(j%==)
printf("C");
else
printf(".");
printf("\n");
}
}
else
{
printf("%d\n",(n+)*(n+)/+(n-)*(n-)/);
for(i=;i<=n;i++)
{
if(i%==)
{
for(j=;j<=n;j++)
if(j%==)
printf("C");
else
printf(".");
printf("\n");
}
else
{
for(j=;j<=n;j++)
if(j%==)
printf("C");
else
printf(".");
printf("\n");
}
}
}
}
return ;
}
CodeForces 384A Coder的更多相关文章
- Codeforces Round #369 (Div. 2)---C - Coloring Trees (很妙的DP题)
题目链接 http://codeforces.com/contest/711/problem/C Description ZS the Coder and Chris the Baboon has a ...
- Codeforces Round #372 (Div. 2)
Codeforces Round #372 (Div. 2) C. Plus and Square Root 题意 一个游戏中,有一个数字\(x\),当前游戏等级为\(k\),有两种操作: '+'按钮 ...
- Codeforces Round #369 (Div. 2) C. Coloring Trees(dp)
Coloring Trees Problem Description: ZS the Coder and Chris the Baboon has arrived at Udayland! They ...
- Codeforces 715B & 716D Complete The Graph 【最短路】 (Codeforces Round #372 (Div. 2))
B. Complete The Graph time limit per test 4 seconds memory limit per test 256 megabytes input standa ...
- Codeforces 715A & 716C Plus and Square Root【数学规律】 (Codeforces Round #372 (Div. 2))
C. Plus and Square Root time limit per test 2 seconds memory limit per test 256 megabytes input stan ...
- Codeforces 716A Crazy Computer 【模拟】 (Codeforces Round #372 (Div. 2))
A. Crazy Computer time limit per test 2 seconds memory limit per test 256 megabytes input standard i ...
- Codeforces 716B Complete the Word【模拟】 (Codeforces Round #372 (Div. 2))
B. Complete the Word time limit per test 2 seconds memory limit per test 256 megabytes input standar ...
- codeforces 369 div2 C dp
http://codeforces.com/contest/711 C. Coloring Trees time limit per test 2 seconds memory limit per t ...
- Codeforces Round #396.D
D. Mahmoud and a Dictionary time limit per test 4 seconds memory limit per test 256 megabytes input ...
随机推荐
- [OrangePi] If you are using an older image
Download scriptbin_kernel.tar.gz from Mega, unpack. Copy uImage_OPI-2 or uImage_OPI-PLUS (depending ...
- batch批的概念
批处理(Batch Requests), 批处理简单理解为同时执行的一批SQL处理语句,一个批处理中可能有多个DML.多个存储过程等等.如在SSMS操作,每个'GO'执行前都属于一个批处理. 注意区分 ...
- [经典php视频]构建正则表达式解析网页中的图像标记<img>
这是高洛峰php视频中的一段,视频中一边分析需要的功能,一边构建greg_match函数的参数,边讲解边实战,是非常好的一种构建功能的演示. 你不可能把浩瀚的IT资料都记在脑袋里,也不可能随时随地透过 ...
- JavaScript获取后台C#变量以及调用后台方法
http://www.educity.cn/develop/495493.html 有时需要在JavaScript中获取后台变量的值,来判断JavaScript的执行逻辑,或者需要调用C#后台方法获取 ...
- How to change Jenkins default folder on Windows?
http://stackoverflow.com/questions/12689139/how-to-change-jenkins-default-folder-on-windows accepted ...
- Java编程思想重点
1. Java中的多态性理解(注意与C++区分) Java中除了static方法和final方法(private方法本质上属于final方法,因为不能被子类访问)之外,其它所有的方法都是动态绑定,这意 ...
- 【python cookbook】【数据结构与算法】6.在字典中将键映射到多个值上
问题:一个能将键(key)映射到多个值的字典(即所谓的一键多值字典[multidict]) 解决方案:如果想让键映射到多值,需要将这多个值保持到另一个容器如列表或集合中: >>> d ...
- 161117、使用spring声明式事务抛出 identifier of an instance of
今天项目组有成员使用spring声明式事务出现下面异常,这里跟大家分享学习下. 异常信息: org.springframework.orm.hibernate3.HibernateSystemExce ...
- seo伪原创技术原理分析,php实现伪原创示例
seo伪原创技术原理分析,php实现伪原创示例 现在seo伪原创一般采用分词引擎以及动态同义词库,模拟百度(baidu),谷歌(google)等中文切词进行伪原创,生成后的伪原创文章更准确更贴近百度和 ...
- flexbox in IE (10+ and 9 and 8)
.parent { display: -webkit-box !important; display: -moz-box !important; display: -ms-flexbox !impor ...