清泽心雨 移动互联 2016 笔试模拟题 题解
来源:互联网 发布:js包装函数是什么 编辑:程序博客网 时间:2024/05/01 00:20
这次模拟题的难度类比考试题,会有难度梯度,也尽量能够区分大家的编程水平,正式考试时间为2个小时,一共5道题,题目不排除有英文的可能,允许查字典,考试地点届时看群公告,题解会随后发出,会有1道题涉及较复杂算法,有1道题较简单的算法但逻辑能力要求较强,有三道题为简单题,考验大家的编程水平,考试会有实时排名,排名的分数和AC题的时间,提交错误的罚时都会有影响,我们最终将根据排名,辅助其它方面一同决定最终留下的人员。
大家重点解题的具体思路,我不会给出每一句代码的思路,要自己阅读,仔细思考,加油!
A:A+B 简单题
Solution:
水题,希望大家熟悉环境,掌握输入输出的技巧,最后要有一个\n
#include<cstdio>using namespace std;int main(){ int a,b; while(~scanf("%d%d",&a,&b)){ printf("%d\n",a+b); } return 0;}
B:前n项和 简单题
Solution:
前n项和公式为:n*(n+1)/2,注意到结果可能在32位有符号整数之内,但是运算过程中两数相乘就有可能溢出,我们索性就用long long,别忘了每一个结果后跟一个空行。
#include<cstdio>using namespace std;int main(){ long long n,sum; while(~scanf("%lld",&n)){ sum = n*(n+1)/2; printf("%lld\n\n",sum); } return 0;}
C:A*B 难题
Solution:
单纯的利用字符串进行模拟高精度乘法效率不够高,会出现TLE,所以我们需要使用NTT(快速数论变换)或者FFT(快速傅里叶变换)来求卷积,把10,100分别理解成阶.
这道题想带给大家的收获:
看起来简单的问题不一定简单,要对数字溢出有概念,要对效率有追求,对相关算法感兴趣的同学可以继续了解,不感兴趣的同学可以直接跳过,考试时如果做出这个难度的题那真的是一个不可多得人才。
此题较难,单独列出我的另一篇博文:
题解:http://blog.csdn.net/cfarmerreally/article/details/52668610
D:日期转换 简单题
Solution:
字符串处理,编程时注意相关的细节,也希望大家找到适合自己的代码风格。
#include <stdio.h> char *sampm[] = {"am", "pm"}; int main() { int t; int year, month, day, hour, minute, second; int ampm; scanf("%d", &t); while(t--){ scanf("%d/%d/%d-%d:%d:%d", &year, &month, &day, &hour, &minute, &second); if(hour >= 12) ampm = 1; else ampm = 0; if(hour == 0) hour = 12; else if(hour > 12) hour -= 12; printf("%02d/%02d/%04d-%02d:%02d:%02d%s\n", month, day, year, hour, minute, second, sampm[ampm]); } return 0; }
E: 字母转转转 中等题
Solution:
主要考验大家的细心和编程能力,本身不要求什么算法和数据结构,大家代码都好长,而我利用了两个数组表示方向,起个名字就叫方向数组吧。
#include<cstdio>#include<cstring>using namespace std;char str[1000][1000];int main(){ memset(str,0,sizeof(str)); int dirx[4] = {1,0,-1,0}; int diry[4] = {0,1,0,-1}; int r, c, idx = 0, dir = 0; int now = 0, tot; int x = 1, y = 1; scanf("%d%d",&r,&c); tot = r*c; for(int i = 0; i <= c+1; ++i){ str[0][i] = '#'; str[r+1][i] = '#'; } for(int i = 0; i <= r+1; ++i){ str[i][0] = '#'; str[i][c+1] = '#'; } while(now < tot){ str[y][x] = 'A'+idx; while(str[y+diry[dir]][x+dirx[dir]] != '\0' && now != tot-1) dir = (dir+1)%4; x += dirx[dir]; y += diry[dir]; now++; idx = (idx+1)%26; } for(int i = 1; i <= r; ++i){ for(int j = 1; j <= c; ++j) printf(" %c",str[i][j]); printf("\n"); } return 0;}
F:汉诺塔 中等题
Solution :
代码不长,主要考验大家的递归思维能力。
//代码来源于网络
#include <stdio.h> __int64 bit[64] = {1}; int flag ; void dfs(int a,int b,int c,int n,__int64 m) { if(flag) return ; if(!n) return ; if(m > bit[n - 1]) dfs(b,a,c,n-1,m-bit[n-1]); else if(m == bit[n-1]) { printf("%d %d %d\n",n,a,c); flag = 1; return ; } else dfs(a,c,b,n-1,m); } int main() { for(int i = 1; i < 64; ++i) bit[i] = bit[i - 1] << 1; int n,t; __int64 m; scanf("%d",&t); int a = 1, b = 2, c = 3; while(t--) { scanf("%d%I64d",&n,&m); flag = 0; dfs(a,b,c,n,m); } return 0; }
G:萌萌哒数(水仙花数) 简单题
Solution:
经典问题,编程模拟过程即可,考验大家的基础编程能力,并且适应环境。
#include <iostream> using namespace std; int main(){ int m,n,i; while(cin>>m>>n) { if (m > n) { int temp = m; m = n; n = temp; } bool flag = false; int count = 0; for (i = m; i <= n; i++) { int a,b,c,s = i; a = s % 10; s = s / 10; b = s % 10; s = s / 10; c = s; s = a * a * a +b * b * b +c * c * c; if (s == i) { if (count != 0) cout<<" "; cout<<i; flag = true; count++; } } if (flag) cout<<endl; else cout<<"no"<<endl; } return 0; }
H:排序
Solution:
主要是让大家体会排序的编程思想,题目本身很简单,但是希望能从代码中看到大家手动实现的排序,通过对题目所给字符串的处理得到一些数字,然后对数字排序,关于排序我在另一篇博客中提到了计数排序等O(n)复杂度的排序,快排是(O(nlgn)级别),
http://blog.csdn.net/cFarmerReally/article/details/52123990?locationNum=1
#include <iostream> using namespace std; int comp(const void *a,const void *b) { return *(int *)a-*(int *)b; } int main() { int i, j, k, a[1000], acount; char str[1001], temp[10]; while(cin>>str) { j = 0; acount = 0; k = strlen(str); if (str[k-1] != '5') str[k++] = '5'; for(i = 0; i < k; i++) { if(str[i] == '5') { if(j != 0) { temp[j] = ' '; a[acount++] = atoi(temp); j = 0; } } else temp[j++] = str[i]; } qsort(a, acount, sizeof(a[0]), comp); for(i = 0; i < acount-1; i++) cout<<a[i]<<" "; cout<<a[acount-1]<<endl; } return 0; }
希望大家能在这次模拟中有所收获,对环境充分熟悉,也希望大家最终能够取得好成绩
- 清泽心雨 移动互联 2016 笔试模拟题 题解
- 笔试真题解析 TT-2016 研发工程师在线模拟笔试题
- 2016腾讯模拟笔试题
- 2014木瓜移动校园招聘笔试题之递归优化题解答
- NOIP模拟题题解
- 【笔试题】模拟笔试题
- 2016大唐移动 在线笔试题
- 猎豹移动2016研发工程师笔试题
- 移动笔试题(仅供参考)
- 移动研究院笔试题
- 猎豹移动笔试题
- 笔试题的JAVA题解.
- 2016美团秋招笔试模拟
- Android模拟笔试题
- C语言中的面向对象技术---模拟对象(百度移动端笔试题之一)
- 网易2016Java实习生笔试题最后一题题解
- 对于移动平均算法,是计算某变量之前n个数值的算术平均,正确的说法是:----腾讯2016研发工程师在线模拟笔试题
- 笔试真题解析 2016 SYDZ 校招在线笔试题
- 代码注释中的5要与3不要
- 剑指Offer面试题25(Java版):二叉树中和为某一值的路径
- Android中SharedPreferences使用方法介绍
- BZOJ3747[POI2015] Kinoman
- BNUOJ 52310 Similarity of Subtrees
- 清泽心雨 移动互联 2016 笔试模拟题 题解
- 仅此而已的8,9月の总结
- NOIP2016提高组 五校联考1 总结
- 3.6 响应系统设置的事件(Configuration类)
- DEVC++(2)多文件实现重载运算符的十六进制数类
- Makefile
- 软考之文法
- 前端面试题汇总(二)含解答
- UOJ 58 [WC2013]糖果公园