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 ...
随机推荐
- 【sinatra】修改默认ip绑定
加入 # 默认的bind是127.0.0.1 set :bind, '0.0.0.0' #0.0.0.0之后你能通过lan访问这个服务器
- DIV怎样能够垂直居中
这里只说固定宽高的情况: 1.Top:50%; 2.margin-top:-(height/2); 就这样. 不过很好奇有没有v-align之类的属性可以直接实现.
- linux终端快捷键
tab 补全 ctrl+k 删除此处到末尾所有内容 ctrl+u 删除此处到开始所有内容 ctrl+a 将光标移至开始处 cttl+e 将光标移至结尾 ctrl+l 清屏 ctrl+c 删除整行或停止 ...
- Linux系统中“动态库”和“静态库”那点事儿【转】
转自:http://blog.chinaunix.net/uid-23069658-id-3142046.html 今天我们主要来说说Linux系统下基于动态库(.so)和静态(.a)的程序那些猫腻. ...
- struts2上传
注意事项:文件名必须是:文件域+FileName,如: // 封装上传文件域的属性 private File uploadImage; // 封装上传文件名的属性 private String upl ...
- plsql日期乱码
乱码状况如截图: 控制面板\所有控制面板项\系统\高级系统设置\环境变量, 设置系统变量,变量名:NLS_LANG,变量值:Simplified Chinese_China.AL32UTF8改为SIM ...
- golang的helloworld
新建源码文件hello.go mkdir -p /work/goTest/ cd /work/goTest/ vim hello.go 编码hello.go文件: package main impor ...
- XCode5 真机调试及发布应用
一.XCODE 真机测试 Xcode5已经很智能,只需生成一个开发证书,安装后,插入设备会自动添加,注意,当Mac系统升级后,证书需要重新生成. 证书生成步骤: 1.生成 CertificateSig ...
- HDU 1827:Summer Holiday(强连通)
http://acm.hdu.edu.cn/showproblem.php?pid=1827 思路:强连通分量缩点后找入度为0的点,然后对于属于该强连通分量的找一个最小耗费的入口. #include ...
- [HTML]DIV+CSS 文字垂直居中
在说到这个问题的时候,也许有人会问CSS中不是有vertical-align属性来设置垂直居中的吗?即使是某些浏览器不支持我只需做少许的CSS Hack技术就可以啊!所以在这里我还要啰嗦两句,CSS中 ...