五:斐波那契数列

代码

#include <iostream>
#include <cstring>using namespace std;
typedef long long ll;
const int N = 10010;
ll a[N];
int n;int main()
{cin >> n;a[1] = 1;a[2] = 1;for(int i = 3; i <= n + 1; i++){a[i] = a[i - 1] + a[i - 2];// cout << i << " " << a[i] << endl;}cout << a[n + 1] << endl;return 0;}

六:代金券组合
搜索写法(40%)
代码

#include <iostream>
#include <cstring>
#include <algorithm>using namespace std;
typedef long long ll;
const int N = 10010;
int a[N];
int n, p;
int ans = 0x3f3f3f3f;
bool f;void dfs(int r, int num)
{if(num >= ans) return;if(r == 0){ans = min(ans, num);}if(r < 0) return;for(int i = 1; i <= n; i++){dfs(r - a[i], num + 1);}return;
}int main()
{while(cin >> p && p){f = false;cin >> n;for(int i = 1; i <= n; i++)cin >> a[i];sort(a + 1, a + n + 1);reverse(a + 1, a + 1 + n);dfs(p, 0);}cout <<ans << endl;return 0;}

DP代码 完全背包

#include <iostream>
#include <cstring>
#include <algorithm>using namespace std;
typedef long long ll;
const int N = 10010;
int a[N];
int n, p;
int f[N];int main()
{while(cin >> p && p){cin >> n;for(int i = 1; i <= n; i++)cin >> a[i];memset(f, 0x3f, sizeof f);f[0] = 0;for(int i = 1; i <= n; i++)for(int j = a[i]; j <= p; j++){f[j] = min(f[j], f[j - a[i]] + 1);}if(f[p] > 0x3f3f3f3f / 2)cout << "Impossible" << endl;else cout << f[p] << endl;}return 0;}

七:迷宫寻路

代码

#include <iostream>
#include <cstring>
#include <algorithm>using namespace std;
typedef long long ll;
const int N = 110;
int a[N][N];
int f[N][N];int n, m;int main()
{cin >> n >> m;for(int i = 1; i <= n; i++)for(int j = 1; j <= m; j++)cin >>a[i][j];memset(f, 0x3f, sizeof f);f[1][1] = a[1][1];for(int i = 1; i <= n; i++)for(int j = 1; j <= m; j++){if(i == 1 && j == 1) continue;f[i][j] = min(f[i - 1][j], f[i][j - 1]);f[i][j] += a[i][j];}cout << f[n][m] << endl;return 0;}

八:星际穿越
代码

#include <iostream>
#include <cstring>
#include <algorithm>using namespace std;typedef long long ll;int a[10][10][10];
bool vis[10][10][10];
int n;
int xx, yy, zz, maxx = 0;
int ans = 0;void dfs(int x, int y, int z, int num)
{ans = max(ans, num);int fx = x - 1;int fy = y;int fz = z;if (fx >= 0 && fx < n && !vis[fx][fy][fz] && a[fx][fy][fz] < a[x][y][z]){vis[fx][fy][fz] = true;dfs(fx, fy, fz, num + a[fx][fy][fz]);vis[fx][fy][fz] = false;}fx = x + 1;fy = y;fz = z;if (fx >= 0 && fx < n && !vis[fx][fy][fz] && a[fx][fy][fz] < a[x][y][z]){vis[fx][fy][fz] = true;dfs(fx, fy, fz, num + a[fx][fy][fz]);vis[fx][fy][fz] = false;}fx = x;fy = y - 1;fz = z;if (fy >= 0 && fy < n && !vis[fx][fy][fz] && a[fx][fy][fz] < a[x][y][z]){vis[fx][fy][fz] = true;dfs(fx, fy, fz, num + a[fx][fy][fz]);vis[fx][fy][fz] = false;}fx = x;fy = y + 1;fz = z;if (fy >= 0 && fy < n && !vis[fx][fy][fz] && a[fx][fy][fz] < a[x][y][z]){vis[fx][fy][fz] = true;dfs(fx, fy, fz, num + a[fx][fy][fz]);vis[fx][fy][fz] = false;}fx = x;fy = y;fz = z - 1;if (fz >= 0 && fz < n && !vis[fx][fy][fz] && a[fx][fy][fz] < a[x][y][z]){vis[fx][fy][fz] = true;dfs(fx, fy, fz, num + a[fx][fy][fz]);vis[fx][fy][fz] = false;}fx = x;fy = y;fz = z + 1;if (fz >= 0 && fz < n && !vis[fx][fy][fz] && a[fx][fy][fz] < a[x][y][z]){vis[fx][fy][fz] = true;dfs(fx, fy, fz, num + a[fx][fy][fz]);vis[fx][fy][fz] = false;}
}int main()
{cin >> n;for (int i = 1; i <= n * n * n; i++){int x, y, z;cin >> x >> y >> z;int p;cin >> p;a[x][y][z] = p;if (p > maxx){xx = x;yy = y;zz = z;maxx = p;}}vis[xx][yy][zz] = true;dfs(xx, yy, zz, maxx);cout << ans << endl;return 0;
}

美团点评2020校招前端方向笔试题相关推荐

  1. 【美团点评2020校招测试方向笔试题】算法题部分1.删除字符 2.队列组合排序 3.寻找最小子字符串 4.最大矩形 5.最短送餐路程计算

    做题网址:点击进入 1.[编程题]删除字符 将给定的字符串,按照规则删除字符,输出删除后的字符串.删除规则为:相同字符连续,则删除,如"aaaab"删除后的字符串为"b& ...

  2. 美团点评2020校招测试方向笔试题

    一: 直接输出, 用flag记录是否有答案,一次循环,时间复杂度O(n). 代码 #include <iostream> #include <cstring> #include ...

  3. 美团点评2020校招数据分析方向笔试题

    说明关系型数据库通过索引提升查询效率的背后原理 . 如果没有索引,数据库引擎需要通过全表扫描来查找数据,这会产生大量的磁盘IO. 关系型数据库使用B+树构建索引来加速加快查询.B+树是一种二叉查找树( ...

  4. 美团2020校招前端方向笔试题

    1.简答题1 答案: 1. i,s,a都在栈中,new出来的对象A在堆上. 2. 执行完后a.i的值还是字符串op. 解析: 1.考察js堆与栈:栈内存主要用于存储各种基本类型的变量,包括Boolea ...

  5. 美团点评2020年测试工程师笔试题

    VOL 155 04 2020-09 今天距2021年118天 这是ITester软件测试小栈第155次推文 点击上方蓝字"ITester软件测试小栈"关注我,每周一.三.五早上  ...

  6. 美团点评校招前端方向笔试题

    1. 请按顺序写出打印结果,并说明原因. var name = 'global'; var obj = {name: 'local',foo: function(){this.name = 'foo' ...

  7. 美团校招php笔试题,【美团点评】2020校招数据分析方向笔试题

    这几天做了下美团校招的一些套题.(只写了编程,这两天慢慢更新吧) 这套题还是蛮简单的..我暴力了好几个都能过.一个小时多一点差不多能写完. 4.棋子翻转 题意:在4*4的棋盘上摆满了黑白棋子,黑白两色 ...

  8. 牛客_美团点评2020校招前端笔试题(仅个人学习记录)

    1.(问答题) 题目描述 class A { String i = "op"; void func(String s) { s = ""+9; } static ...

  9. 爱奇艺2020校招Java方向笔试题(第一场)

    1. 计算下列程序的时间复杂度(B) for (i=1;i<n;i++)for(j=1;j<m;j++){a1,a2,a3,a4}; A. O(n) B. O(nm) C. O(m) D. ...

最新文章

  1. 李宏毅机器学习笔记(五)-----Where does the error come from
  2. 大中型企业的天网:Apache Geode
  3. windows下wchar_t* 转char*
  4. python解释器的安装步骤-Python本地及虚拟解释器配置过程解析
  5. python绘制雷达图代码实例-Matplotlib绘制雷达图和三维图的示例代码
  6. 关于for中思维卡机的小悲剧
  7. DataTable to byte[]、DataTable to XML(string)
  8. 【收集】47种常见的浏览器兼容性问题
  9. svn上传报Authorization failed错误解决办法
  10. Android应用性能优化整体策略
  11. SATA学习笔记 1 --- ATA、IDE、ATAPI、SCSI、SATA、SAS等概念澄清
  12. vue H5 唤醒app
  13. linux/ubuntu16.04系统上snowboy swig源码安装及使用全记录和遇到的错误
  14. 怎么做SWOT分析模型PPT呢?
  15. java oa开发_oa开发方案
  16. html刷浏览量,批量刷网页点击量工具
  17. 大数据与云计算——Vmware虚拟化技术原理
  18. 健身健美补剂之蛋白粉
  19. MobaXterm上方工具栏显示
  20. 利用OA系统进行档案管理原来这么简单?

热门文章

  1. NC17389-凤 凰(并查集)
  2. linux服务器 使用教程
  3. 天刀手游服务器注册不了,天涯明月刀手游开服常见问题汇总 天涯明月刀手游10月16日开服...
  4. 数字孪生轨道交通:“智慧化”监控疏通城市运行痛点
  5. vc6创建dll文件的步骤_创建真正有用的产品支持页面的6步骤计划
  6. HIVE常用命令之MSCK REPAIR TABLE命令简述
  7. Windows程序以特定用户身份运行
  8. STM32 PWM控制舵机——原理、接线、源程序
  9. 实践GoF的23种设计模式:建造者模式
  10. python飞机大战没有运行界面_python3实现飞机大战