做题痕迹


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
const readline = require('readline')
const rl = readline.createInterface({
input:process.stdin,
output:process.stdout
})

rl.on("line",(res)=>{
main(parseInt(res))
})

function main(n){
let m= Array(2*n-1).fill(0).map(item=>
Array(2*n-1).fill(0)
);
for (let i = 0; i < 2*n-1; i++) {
m[i][i]=1
m[i][2*n-2-i]=1
m[n-1][i]=1
m[i][n-1]=1
if(i<n){
m[0][2*n-2-i]=1
m[i][0]=1
m[2*n-2][i]=1
m[n-1+i][2*n-2]=1
}
}
for (let i = 0; i < 2*n-1; i++) {
for (let j = 0; j < 2*n-1; j++) {
if(m[i][j]){
process.stdout.write("*")
}else{
process.stdout.write(" ")
}

}
console.log()
}
}
main(3)




// let n,p,x;
// let calc,arr;
// let time = 0

// if(time==0){
// arr=res.split(' ').map(x=>parseInt(x));
// n = arr[0]
// p = arr[1]
// x = arr[2]
// }else{
// calc = res.split(' ').map(x=>parseInt(x))
// }

// time++;
// if(time==2){
// main(n,p,x,calc)
// rl.close();
// }

// function main(n,p,x,calc){
// let sum=0;
// for (let i = 0; i < n; i++) {
// sum+=calc[i];
// }
// let res = 0;
// for (let i = 0; i < n; i++) {
// let my = sum-calc[i]
// let now = parseInt(my/x);
// let after = parseInt((my+p)/x)
// res+=after-now
// if(calc[i]<=p&&sum%x==0)res--
// }
// console.log(res);
// }


Author: pkq
Reprint policy: All articles in this blog are used except for special statements CC BY 4.0 reprint policy. If reproduced, please indicate source pkq !
  TOC