-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathA.cpp
43 lines (38 loc) · 871 Bytes
/
A.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
ll n, state = 0, cnt = 0;
cin >> n;
char ara[n + 5][n + 5];
for(ll i = 1; i <= n; i++) {
state ^= 1;
for(ll j = 1; j <= n; j++) {
if(state == 1) {
if(j % 2 != 0) {
ara[i][j] = 'C';
cnt++;
}
else
ara[i][j] = '.';
}
else {
if(j % 2 == 0) {
ara[i][j] = 'C';
cnt++;
}
else
ara[i][j] = '.';
}
}
}
cout << cnt << endl;
for(ll i = 1; i <= n; i++) {
for(ll j = 1; j <= n; j++) {
printf("%c", ara[i][j]);
}
printf("\n");
}
return 0;
}