luozha
luozha
全部文章
分类
题解(21)
归档
标签
去牛客网
登录
/
注册
luozha的博客
命数如织,当为磐石
全部文章
(共21篇)
题解 | #字符统计#
let str; while ((str = readline())) { let obj = {}; for (let i = 0; i < str.length; i++) { obj[str[i]] = (obj[str[i]] || 0) + 1; } let ...
Javascript V8
Javascript Node
HTML/CSS/JavaScript
2022-05-29
2
290
题解 | #统计每个月兔子的总数#
let num while(num = parseInt(readline())){ // dp[i] 表示第 i 月的兔子总数 let dp = new Array(num + 1).fill(0) dp[1] = 1 dp[2] = 1 dp[3] = 2 for(let ...
Javascript V8
Javascript Node
HTML/CSS/JavaScript
2022-05-29
0
218
题解 | #汽水瓶#
let num; while ((num = parseInt(readline()))) { // 解法1 // let res = 0; // while (num >= 3) { // let value = Math.floor(num / 3); // r...
Javascript V8
Javascript Node
HTML/CSS/JavaScript
2022-05-28
3
410
题解 | #火车进站#
function dispatch(trains, inOrder, outOrder) { if (outOrder.length === num) { res.push(parseInt(outOrder.join(""))); } if (trains.length ===...
Javascript V8
Javascript Node
HTML/CSS/JavaScript
2022-05-28
2
484
题解 | #二维数组操作#
class Table { constructor(x, y) { this.x = x; this.y = y; } success() { print(0); } fail() { print(-1); } init() { l...
Javascript V8
Javascript Node
HTML/CSS/JavaScript
2022-05-27
5
310
题解 | #将真分数分解为埃及分数#
function gcd(a, b){ if(a % b === 0) return b return gcd(b, a % b) } let str while(str = readline()){ // 由 b / a = q ··· r 得 b = aq + r // a /...
Javascript V8
Javascript Node
HTML/CSS/JavaScript
2022-05-27
2
256
题解 | #放苹果#
// 设f(m,n) 为m个苹果,n个盘子的放法数目,则先对n作讨论, // 当n>m:必定有n-m个盘子永远空着,去掉它们对摆放苹果方法数目不产生影响。即if(n>m) f(m,n) = f(m,m) // 当n<=m:不同的放法可以分成两类: // 1、有至少一个盘子空着,即相...
Javascript V8
Javascript Node
HTML/CSS/JavaScript
2022-05-26
3
424
题解 | #公共子串计算#
动态规划 let str; while ((str = readline())) { let text1 = str; let text2 = readline(); const m = text1.length, n = text2.length; let max = 0;...
Javascript V8
Javascript Node
HTML/CSS/JavaScript
2022-05-26
1
261
题解 | #走方格的方案数#
参考 lc62 let str; while (str = readline()) { // let n = parseInt(str.split(" ")[0]) // let m = parseInt(str.split(" ")[1]) let [n, m] = str.split...
Javascript V8
Javascript Node
HTML/CSS/JavaScript
2022-05-26
0
316
题解 | #计算日期到天数转换#
let str while(str = readline()){ let date = str.replace(/ /, '-') console.log((Date.parse(date) - Date.parse(date.substring(0, 4) + '-01-01'))...
Javascript V8
Javascript Node
HTML/CSS/JavaScript
2022-05-24
0
311
首页
上一页
1
2
3
下一页
末页