-
Notifications
You must be signed in to change notification settings - Fork 0
/
388b2.cpp
80 lines (71 loc) · 1.36 KB
/
388b2.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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
#include <iostream>
#include <cmath>
#include <vector>
using namespace std;
int main() {
int k;
cin >> k;
vector<int> v;
vector<int> u;
int n = 0;
while (k>1 && k%i==0) {
v.push_back(i);
n += i;
k /= i;
}
}
if (k > 1) {
v.push_back(k);
n += k;
}
if (v.size() == 0) {
printf("2\nNY\nYN\n");
return 0;
}
printf("%d\n", n+2);
//1
printf("NN");
for (int j = 0; j < v[0]; j++)
printf("Y");
for (int j = 0; j < n-v[0]; j++)
printf("N");
printf("\n");
//2
printf("NN");
for (int j = 0; j < n-v.back(); j++)
printf("N");
for (int j = 0; j < v.back(); j++)
printf("Y");
printf("\n");
//3 -- n+2
int a, b, c, d;
a = b = c = d = 0;
for (size_t i = 0; i < v.size(); i++) {
a += b;
b = (i==0) ? 0 : v[i-1];
c = (i==v.size()-1) ? 0 : v[i+1];
d = n-a-b-c-v[i];
for (int k = 0; k < v[i]; k++) {
if (i == 0)
printf("Y");
else
printf("N");
if (i == v.size()-1)
printf("Y");
else
printf("N");
for (int j = 0; j < a; j++)
printf("N");
for (int j = 0; j < b; j++)
printf("Y");
for (int j = 0; j < v[i]; j++)
printf("N");
for (int j = 0; j < c; j++)
printf("Y");
for (int j = 0; j < d; j++)
printf("N");
printf("\n");
}
}
return 0;
}