【蘑菇街笔试】
来源:互联网 发布:lol账号解封软件 编辑:程序博客网 时间:2024/04/28 19:51
1 校车
就跟生活中排队上车一样,班级顺序不能乱,同一个班级必须同一辆车,一辆车可以有不同的班级。
#include <stdio.h>#include <math.h>#include <string.h>#include <algorithm>#include <iostream>#include<stdio.h>using namespace std;int arr[200];int main(){ int n, m, cnt=0, tmp; scanf("%d %d", &n, &m); tmp = m; for(int i=0; i<n; i++){ int num; scanf("%d", &num); if(tmp-num < 0){ cnt++; tmp = m; } tmp -= num; } if(tmp != m) cnt++; printf("%d", cnt); return 0;}
2 最大间隙
去掉递增序列中a2,…,an-1中的某一个ai,求剩下的a1,…,ai-1,ai+1,…,an中的最大间隙中的最小值
#include <stdio.h>#include <math.h>#include <string.h>#include <algorithm>#include <iostream>#include<stdio.h>using namespace std;int arr[200], n;int calmax(int x){ int rt = -0x3f3f3f3f; for(int i=2; i<=n; i++) { if(i == x)continue; if(i == x+1) rt = max(rt, arr[i]-arr[i-2]); else rt = max(rt, arr[i]-arr[i-1]); } return rt;}int main(){ scanf("%d", &n); for(int i=1; i<=n; i++) scanf("%d", &arr[i]); if(n==1) { printf("%d\n", arr[1]); return 0; } if(n == 2) { printf("%d\n", arr[2]-arr[1]]); return 0; } int ans = 0x3f3f3f3f; for(int i=2; i<=n-1; i++) ans = min(ans, calmax(i)); printf("%d\n", ans);}
3 搬圆桌
将一个半径为r的圆桌从(x, y)搬到(x1, y1)处,以圆桌边上一点为中心旋转一次称为搬一次,求最少需要搬几次。
#include <iostream>#include <cmath>using namespace std ;int main(int argc, const char * argv[]) { int r, x, y, x1, y1; double length, lx, ly, s; while (cin>>r>>x>>y>>x1>>y1) { lx = (x1-x)>=0 ? (x1-x) : (x-x1); ly = (y1-y)>=0 ? (y1-y) : (y-y1); length = sqrt(lx*lx + ly*ly); s = length/(2*r); int t = (int)s; if (s - t > 0) cout << t+1 <<endl; else cout << t << endl; } return 0;}
0 0
- 【蘑菇街笔试】
- 蘑菇街实习生笔试题
- 蘑菇街笔试题5
- 蘑菇街笔试题1
- 蘑菇街笔试题总结
- 蘑菇街2016招聘笔试
- 蘑菇街2016实习生笔试面试总结
- 蘑菇街2016招聘在线笔试题
- 笔试题(蘑菇街):最大间隔
- 笔试题(蘑菇街):回文串
- 爱情数字(蘑菇街在线笔试)
- 蘑菇街笔试题 搬圆桌
- 蘑菇街笔试题 最大间隔
- 蘑菇街笔试题 投篮比赛
- 蘑菇街笔试--剪桌腿的最小代价
- 蘑菇街2017春招笔试
- 特殊交换(蘑菇街笔试题)
- 蘑菇街三人斗地主随机发牌的笔试题
- ccf ISBN
- 如何实现一个无边框Form的移动和改变大小(一)
- LPC1788在外部RAM调试总结
- 控制器的生命周期
- Apache Awstats 安装配置系列 (2)之 apache部署WEB项目(配置多个地址)
- 【蘑菇街笔试】
- mysql:管理mysql
- HDU 5455 Fang Fang (水题 模拟)
- JSP报错:The superclass "javax.servlet.http.HttpServlet" was not found on the Java Build Path
- Cocos2dx 3.0 过渡篇(三) 触摸机制
- nodejs服务器搭建
- iOS ui设计的乐土
- httrack命令行使用方法
- 黑马程序员--C 语言学习笔记之简介