-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
0 additions
and
182 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,98 +0,0 @@ | ||
// 1-100循环报数 报到m的人退出,输出最后留下的人的序号 | ||
// 以下代码通过80%测试用例, 剩下的某些case提示超时 | ||
|
||
|
||
|
||
// let m = +readline() | ||
let m = 4 | ||
if (m <= 1 || m >= 100) { | ||
console.log('ERROR') | ||
} | ||
|
||
let arr = Array(100).fill(0).map((it, index) => index + 1) | ||
|
||
|
||
// let count = 0 | ||
// for (let i = 0; i < arr.length && arr.length >= m; i++) { | ||
// count++ | ||
// if (count === m) { | ||
// arr.splice(i,1) | ||
// i-- | ||
// count = 0 | ||
// } | ||
// if (i >= arr.length-1 && arr.length >= m) { | ||
// i = -1 | ||
// } | ||
// } | ||
// console.log(arr.join(",")) | ||
|
||
|
||
|
||
let count = 0 | ||
let index = -1 | ||
while (arr.length >= m) { | ||
count++ | ||
index++ | ||
if (count === m) { | ||
arr.splice(index, 1) | ||
index-- | ||
count = 0 | ||
} | ||
if (index >= arr.length - 1) { | ||
index = -1 | ||
} | ||
// if (arr.length < m) break | ||
} | ||
console.log(arr.join(",")); | ||
|
||
|
||
|
||
function circle(arr, interval, final = 1, index = 0, delCount = 0) { | ||
while (arr.length > final) { | ||
index += interval - 1 | ||
// if (index >= arr.length) { | ||
// console.log(`index长度${index}>=数组长度${arr.length}`); | ||
// } | ||
index %= arr.length | ||
const deleted = arr.splice(index, 1) | ||
delCount++ | ||
console.log(`每隔${interval},第${delCount}次删除的下标为${index},值为${deleted},此时数组长度为${arr.length},值为${arr}`); | ||
} | ||
} | ||
let res = circle(Array(50).fill(0).map((it, index) => index + 1), 3) | ||
console.log(res); | ||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
// let count = m | ||
// while (arr.length >= m) { | ||
// for (let i = 0; i < arr.length; i++) { | ||
// if (arr[i] % m === 0) { | ||
// arr.splice(i, 1) | ||
// } | ||
// } | ||
// while () | ||
// } | ||
// const res = arr | ||
// let i = 1 | ||
// let count = m | ||
// let index = 0 | ||
// while (arr.length >= m) { | ||
// if (i === m) { | ||
// arr.splice(i-1, 1) | ||
// } else { | ||
// i++ | ||
// } | ||
// if (index === arr.length - 1) { | ||
// index = 0 | ||
// } | ||
|
||
// } | ||
// return arr.join(",") | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,42 +0,0 @@ | ||
// 考语言基础和命名规范的题,字母多但是不难, 用代码描述三组不等式 | ||
// 以下代码通过 100% 的测试用例 | ||
|
||
|
||
let line = readline() | ||
// let line = '2.3,3,5.6,7,6;11,3,8.6,25,1;0.3,9,5.3,66,7.8;1,3,2,7,5;340,670,80.6;<=,<=,<=' | ||
// let line = '2.36,3,6,7.1,6;1,30,8.6,2.5,21;0.3,69,5.3,6.6,7.8;1,13,2,17,5;340,67,300.6;<=,>=,<=' | ||
let arr = line.split(";") | ||
let [a11, a12, a13, a14, a15] = arr[0].split(",").map(parseFloat) | ||
let [a21, a22, a23, a24, a25] = arr[1].split(",").map(parseFloat) | ||
let [a31, a32, a33, a34, a35] = arr[2].split(",").map(parseFloat) | ||
let [x1, x2, x3, x4, x5] = arr[3].split(",").map(parseFloat) | ||
let [b1, b2, b3] = arr[4].split(",").map(parseFloat) | ||
let [jj1, jj2, jj3] = arr[5].split(",") | ||
|
||
let resB1 = a11 * x1 + a12 * x2 + a13 * x3 + a14 * x4 + a15 * x5 - b1 | ||
let resB2 = a21 * x1 + a22 * x2 + a23 * x3 + a24 * x4 + a25 * x5 - b2 | ||
let resB3 = a31 * x1 + a32 * x2 + a33 * x3 + a34 * x4 + a35 * x5 - b3 | ||
|
||
function judge(v, j) { | ||
if (j === ">") { | ||
return v > 0 | ||
} else if (j === ">=") { | ||
return v >= 0 | ||
} else if (j === "<") { | ||
return v < 0 | ||
} else if (j === "<=") { | ||
return v <= 0 | ||
} else if (j === "=") { | ||
return v === 0 | ||
} | ||
} | ||
|
||
|
||
let resM1 = judge(resB1, jj1) | ||
let resM2 = judge(resB2, jj2) | ||
let resM3 = judge(resB3, jj3) | ||
let resM = resM1 && resM2 && resM3 | ||
|
||
let resN = Math.max(resB1, resB2, resB3) | ||
let resNN = resN > 0 ? Math.floor(resN) : Math.floor(resN) + 1 | ||
console.log(`${resM} ${resNN}`) | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,42 +0,0 @@ | ||
// 每本书的长l宽w, 如果l w均大于另一本书的l w,那么可以叠放,给出数组 求最大可叠放的数的数量 | ||
// 以下代码只通过了 90% 的测试用例 | ||
|
||
|
||
|
||
// console.log(4) | ||
|
||
// let line = readline() | ||
let line = "[[20,16],[15,11],[10,10],[9,10]]" | ||
|
||
let arr0 = JSON.parse(line) | ||
let arr = [...arr0].sort((a, b) => b[0] - a[0]) | ||
|
||
let max = 1 | ||
for (let i = 1; i < arr.length; i++) { | ||
if (arr[i][0] < arr[i - 1][0] && arr[i][1] < arr[i - 1][1]) { | ||
max++ | ||
} | ||
} | ||
console.log(max); | ||
|
||
|
||
|
||
// const readline = require("readline") | ||
// const rl = readline.createInterface(process.stdin, process.stdout) | ||
// rl.on("line", function(line) { | ||
// // let line = "[[20,16],[15,11],[10,10],[9,10]]" | ||
// let arr0 = JSON.parse(line) | ||
// let arr = [...arr0].sort((a, b) => b[0] - a[0]) | ||
|
||
// let max = 1 | ||
// let cur = 1 | ||
// for (let i = 1; i < arr.length; i++) { | ||
// if (arr[i][0] < arr[i - 1][0] && arr[i][1] < arr[i - 1][1]) { | ||
// cur++ | ||
// } else { | ||
// cur = 1 | ||
// } | ||
// max = Math.max(cur, max) | ||
// } | ||
// console.log(max); | ||
// }) | ||
File renamed without changes.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
File renamed without changes.
Empty file.