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 ... 
随机推荐
- 夺命雷公狗—angularjs—24—extend继承对象
			我们的angularjs中也是给我们留下了方法来做继承的,那么他就是传授中的extend... 不过要如下所示,第二个参数是继承到第一个对象里面的... <!DOCTYPE html> & ... 
- 夺命雷公狗---Thinkphp----4之数据表的设计
			我们这次来写的项目是仿http://yispace.net/39765.html而写的, 这里其实也就那回事,主要有标题和内容,和栏目, 文章页就更加的简单,其实也就那及格字段即可,我们分享得出的结果 ... 
- PTPX中的report 选项
			Report的生成 report_power表示产生power report,update_power表示进行power analysis. report_power命令可以生成四种形式的report ... 
- beta-1阶段各组员的贡献分分配
			小组名称:nice! 小组成员:李权 于淼 刘芳芳 韩媛媛 宫丽君 项目内容:约跑app 分数分配规则 个人贡献分=基本贡献分*0.2+特殊贡献分*0.3+个人代码贡献量*0.5 其中 基本贡献分,特 ... 
- windows下快速启动 nginx 和 php-cgi 的两个批处理
			这是启动的批处理: set nginx=D:\nginx-1.9.5\ set php=D:\php\ start /MIN %nginx%nginx.exe start /MIN %php%php- ... 
- 160923、项目管理模式:如何去除SVN标记
			项目管理模式:如何去除SVN标记 当我们从工作空间中拷贝一个项目,发现项目特别大.那是因为当使用svn里面保留了每个版本的信息,我们可以通过这个方法来进行去除 当项目不需要SVN标志的时候,我们一般怎 ... 
- 人工智能大数据,公开的海量数据集下载,ImageNet数据集下载,数据挖掘机器学习数据集下载
			人工智能大数据,公开的海量数据集下载,ImageNet数据集下载,数据挖掘机器学习数据集下载 ImageNet挑战赛中超越人类的计算机视觉系统微软亚洲研究院视觉计算组基于深度卷积神经网络(CNN)的计 ... 
- java继承关系中成员变量,构造方法,成员方法的关系
			Java继承中的成员关系 A:成员变量 a:子类的成员变量名称和父类中的成员变量名称不一样,这个太简单写那个名字就访问那个名字! b:子类的成员变量名称和父类中的成员变量名称一样,这个怎么访问呢? 子 ... 
- (转)java线程安全问题之静态变量、实例变量、局部变量
			java多线程编程中,存在很多线程安全问题,至于什么是线程安全呢,给出一个通俗易懂的概念还是蛮难的,如同<java并发编程实践>中所说: 写道 给线程安全下定义比较困难.存在很多种定义,如 ... 
- 这个Glance的界面该怎么看出问题,为什么状态是SOCKT?
			这个glance的状态图有问题吗? 
