当前位置: 首页 > news >正文

笔试强训(八)

一. 求最小公倍数

题目链接:

https://nowcoder.com/practice/22948c2cad484e0291350abad86136c3?tpId=37&tqId=21331&ru=/exam/oj

#include <iostream>
using namespace std;int gcd(int a, int b)
{if(b == 0) return a;return gcd(b, a % b);
}int main()
{int a, b;cin >> a >> b;cout << (a * b / gcd(a, b)) << endl;return 0;
}

二.数组中的最长连续子序列

题目链接:

https://www.nowcoder.com/practice/eac1c953170243338f941959146ac4bf?tpId=196&tqId=37143&ru=/exam/oj

class Solution {
public:/*** 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可** max increasing subsequence* @param arr int整型vector the array* @return int整型*/int MLS(vector<int>& arr) {// write code heresort(arr.begin(), arr.end());int n = arr.size(), ret = 0;for (int i = 0; i < n;){int j = i + 1, count = 1;while (j < n){if (arr[j] - arr[j - 1] == 1){count++;j++;}else if (arr[j] - arr[j - 1] == 0){j++;}else{break;}}ret = max(ret, count);i = j;}return ret;}
};

三.字母收集

题目链接:

https://www.nowcoder.com/practice/9740ce2df0a04399a5ade1927d34c1e1?tpId=230&tqId=38954&ru=/exam/oj

#include<iostream>using namespace std;
int dp[505][505];
int main()
{int n, m;cin >> n >> m;char a[n][m];for (int i = 0; i < n; i++){for (int j = 0; j < m; j++){cin >> a[i][j];}}for (int i = 1; i <= n; i++){for (int j = 1; j <= m; j++){dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]);if (a[i-1][j-1] == 'l'){dp[i][j] += 4;}else if (a[i-1][j-1] == 'o'){	dp[i][j] += 3;}else if (a[i-1][j-1] == 'v'){dp[i][j] += 2;}else if (a[i-1][j-1] == 'e'){dp[i][j] += 1;}}}cout << dp[n][m] << endl;return 0;
}
http://www.dtcms.com/a/529223.html

相关文章:

  • 山西品牌网站建设成品网站源码68w68游戏
  • Linux内核进程管理子系统有什么第六十八回 —— 进程主结构详解(64)
  • 做网站需要商标注册吗阿里巴巴怎么做企业网站
  • 做视频网站需要哪些技术指标wordpress可以放视频吗
  • 动态库的使用-openssl
  • Maven 项目和 Maven Web 项目的异同点
  • Maven整理
  • 关于OpenAI CLIP的综合技术报告:架构、对比预训练与多模态影响
  • 网上服装商城网站代码软件开发 网站建设
  • 保洁网站模板闲置物品交易网站怎么做
  • 11月更新|流程节点新增数据变更+发起流程
  • 【Swift】LeetCode 189. 轮转数组
  • 聊城网站托管网络舆情处置方案
  • C#的operator运算符定义
  • 南通网站建设论文网站上传用什么软件做视频格式
  • ftp备份网站wordpress进管理员密码
  • 【移动语义】C++ 移动语义的秘传心法
  • 网站营销的优势电商app系统开发公司
  • 电影wordpress福州搜索优化行业
  • 中国建设银行网站软件下载工厂招聘信息
  • 能耗在线监测系统助企业实时监测管理能耗,提升能源利用率
  • 怎么根据别人的网站做自己的网站片头制作网站
  • Python3 标准库概览
  • 从 Transformer 理论到文本分类:BERT 微调实战总结
  • 基于Python利用正则表达式将英文双引号 “ 替换为中文双引号 “”
  • rwqsd
  • 个人网站 建站前端网站优化
  • 【Linux】深入浅出 Linux 自动化构建:make 与 Makefile 的实用指南
  • 六安市城乡建设网站沧州百姓网免费发布信息网
  • 俱乐部网站php源码网站构建的工作