CodeForces 384A Coder

Coder

Time Limit:1000MS     Memory Limit:262144KB     64bit IO Format:%I64d & %I64u

Submit Status Practice CodeForces 384A

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

Input

2

Output

2C..C

 1 #include <stdio.h>
 2 #include <string.h>
 3 int main()
 4 {
 5     int n;
 6     int i,j,k;
 7     while(scanf("%d",&n)!=EOF)
 8     {
 9         if(n%2==0)
10         {
11             printf("%d\n",n*n/2);
12             for(i=1;i<=n/2;i++)
13             {
14                 for(j=1;j<=n;j++)
15                     if(j%2==1)
16                         printf("C");
17                     else
18                         printf(".");
19                 printf("\n");
20                 for(j=1;j<=n;j++)
21                     if(j%2==0)
22                         printf("C");
23                     else
24                         printf(".");
25                 printf("\n");
26             }
27         }
28         else
29         {
30             printf("%d\n",(n+1)*(n+1)/4+(n-1)*(n-1)/4);
31             for(i=1;i<=n;i++)
32             {
33                 if(i%2==1)
34                 {
35                     for(j=1;j<=n;j++)
36                         if(j%2==1)
37                             printf("C");
38                         else
39                             printf(".");
40                     printf("\n");
41                 }
42                 else
43                 {
44                     for(j=1;j<=n;j++)
45                         if(j%2==0)
46                             printf("C");
47                         else
48                             printf(".");
49                     printf("\n");
50                 }
51             }
52         }
53     }
54     return 0;
55 }

时间: 2024-10-08 06:43:00

CodeForces 384A Coder的相关文章

一些学习编程的网站

网课: 慕课网:比较适合作为一个方向的入门,进阶还是需要自己去看书.实战的 优达学城:虽然有很多课程需要付费,部分没有免费的课程,但是亲测,课程质量蛮高的.教学方式也很有特色,需要自己动手去实战. 腾讯课堂:队友跟着里面学windows应用开发,据说感觉不错 Python学习:廖雪峰的python3教程,挺通俗易懂的 菜鸟教程:经常搜一些东西能搜到这个网站,适合遇到问题查询用 freecode camp:一个学习前端的好网站 刷题.编程实践: leetcode 牛客网 计蒜客 PAT codef

Codeforces Round #396 (Div. 2) D题Mahmoud and a Dictionary(并查集)解题报告

Mahmoud wants to write a new dictionary that contains n words and relations between them. There are two types of relations: synonymy (i. e. the two words mean the same) and antonymy (i. e. the two words mean the opposite). From time to time he discov

Codeforces Round #256 (Div. 2) E Divisors

E. Divisors Bizon the Champion isn't just friendly, he also is a rigorous coder. Let's define function f(a), where a is a sequence of integers. Function f(a) returns the following sequence: first all divisors of a1 go in the increasing order, then al

Educational Codeforces Round 73 (Rated for Div. 2)

比赛链接:Educational Codeforces Round 73 (Rated for Div. 2) 官方题解:Educational Codeforces Round 73 Editorial A. 2048 Game 题意 如果一个只包含 \(2\) 的幂次的集合,问能否从中选择一些数使得和为 \(2048\). 思路 不断合并直到凑到 \(2048\). 代码 #include <bits/stdc++.h> using namespace std; int main() {

Codeforces Round #590 (Div. 3)

D. Distinct Characters Queries Description You are given a string ss consisting of lowercase Latin letters and qq queries for this string. Recall that the substring s[l;r]s[l;r] of the string ss is the string slsl+1…srslsl+1…sr. For example, the subs

Codeforces Round #590 (Div. 3) D. Distinct Characters Queries(线段树, 位运算)

链接: https://codeforces.com/contest/1234/problem/D 题意: You are given a string s consisting of lowercase Latin letters and q queries for this string. Recall that the substring s[l;r] of the string s is the string slsl+1-sr. For example, the substrings

【codeforces 718E】E. Matvey&#39;s Birthday

题目大意&链接: http://codeforces.com/problemset/problem/718/E 给一个长为n(n<=100 000)的只包含‘a’~‘h’8个字符的字符串s.两个位置i,j(i!=j)存在一条边,当且仅当|i-j|==1或s[i]==s[j].求这个无向图的直径,以及直径数量. 题解:  命题1:任意位置之间距离不会大于15. 证明:对于任意两个位置i,j之间,其所经过每种字符不会超过2个(因为相同字符会连边),所以i,j经过节点至多为16,也就意味着边数至多

Codeforces 124A - The number of positions

题目链接:http://codeforces.com/problemset/problem/124/A Petr stands in line of n people, but he doesn't know exactly which position he occupies. He can say that there are no less than a people standing in front of him and no more than b people standing b

Codeforces 841D Leha and another game about graph - 差分

Leha plays a computer game, where is on each level is given a connected graph with n vertices and m edges. Graph can contain multiple edges, but can not contain self loops. Each vertex has an integer di, which can be equal to 0, 1 or  - 1. To pass th