微软苏州校招笔试 12月27日

2024-09-02 18:32
文章标签 笔试 校招 微软 27 苏州

本文主要是介绍微软苏州校招笔试 12月27日,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

题目1 : Lost in the City

时间限制: 10000ms
单点时限: 1000ms
内存限制: 256MB

描述

Little Hi gets lost in the city. He does not know where he is. He does not know which direction is north.

Fortunately, Little Hi has a map of the city. The map can be considered as a grid of N*M blocks. Each block is numbered by a pair of integers. The block at the north-west corner is (1, 1) and the one at the south-east corner is (N, M). Each block is represented by a character, describing the construction on that block: '.' for empty area, 'P' for parks, 'H' for houses, 'S' for streets, 'M' for malls, 'G' for government buildings, 'T' for trees and etc.

Given the blocks of 3*3 area that surrounding Little Hi(Little Hi is at the middle block of the 3*3 area), please find out the position of him. Note that Little Hi is disoriented, the upper side of the surrounding area may be actually north side, south side, east side or west side.

输入

Line 1: two integers, N and M(3 <= N, M <= 200).
Line 2~N+1: each line contains M characters, describing the city's map. The characters can only be 'A'-'Z' or '.'.
Line N+2~N+4: each line 3 characters, describing the area surrounding Little Hi.

输出

Line 1~K: each line contains 2 integers X and Y, indicating that block (X, Y) may be Little Hi's position. If there are multiple possible blocks, output them from north to south, west to east.

样例输入
8 8
...HSH..
...HSM..
...HST..
...HSPP.
PPGHSPPT
PPSSSSSS
..MMSHHH
..MMSH..
SSS
SHG
SH.
样例输出
5 4
给出一个n*m的图和一个3*3的图,要求你输出3*3的原图的中心位置的坐标。直接暴力匹配。需要注意一下图是可以旋转的,在求出坐标之后需要先排个序,去个重就好。

代码如下:

/************************************************************************* > 转载请注明出处http://blog.csdn.net/acvcla/article/details/42200345> File Name: xiaozhao.cpp > Author: acvcla > QQ:acvcla@gmail.com  > Mail: acvcla@gmail.com > Created Time: 2014年12月27日 星期一 22时34分13秒 
*************************************************************************/  
#include<cstdio>
#include<iostream>
#include<string>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<queue>
#include<cstdlib>
#include<vector>
#include<set>
#include<map>
#include<stack>
#include<climits>
using namespace std;
const int maxn = 1e5 + 10;
typedef long long ll;
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define pb push_backstring str[200];
string area[3];
int n, m;
void rotate()
{int n=3;for(int i=0;i<n;i++)for(int j=i+1;j<n;j++)swap(area[i][j],area[j][i]);for(int i=0;i<n;i++)for(int j=0;j<n/2;j++)swap(area[i][j],area[i][n-1-j]);
}
bool judge(int x,int y)
{for(int i=0;i<3;i++)for(int j=0;j<3;j++) {if(area[i][j]!=str[x+i][j+y])return false;}return true;
}
void solve()
{vector<pair<int,int> >v;v.clear();for(int i=0;i<4;i++) {for(int i=0;i+2<n;i++) {for(int j=0;j+2<m;j++) {if(judge(i,j)) {v.push_back(make_pair(i+2,j+2));}}}rotate();}sort(v.begin(), v.end());int cnt=unique(v.begin(), v.end())-v.begin();for(int i=0;i<cnt;i++)cout<<v[i].first<<' '<<v[i].second<<endl;
}
int main()
{while(cin>>n>>m) {for(int i=0;i<n;i++)cin>>str[i];for(int i=0;i<3;i++)cin>>area[i];solve();}return 0;
}





题目2 : HIHO Drinking Game

时间限制: 10000ms
单点时限: 1000ms
内存限制: 256MB

描述

Little Hi and Little Ho are playing a drinking game called HIHO. The game comprises N rounds. Each round, Little Hi pours T milliliter of water into Little Ho's cup then Little Ho rolls a K-faces dice to get a random number d among 1 to K. If the remaining water in Little Ho's cup is less than or equal to d milliliter Little Hi gets one score and Little Ho drinks up the remaining water, otherwise Little Ho gets one score and Little Ho drinks exactly d milliliter of water from his cup. After N rounds who has the most scores wins.

Here comes the problem. If Little Ho can predict the number d of N rounds in the game what is the minimum value of T that makes Little Ho the winner? You may assume that no matter how much water is added, Little Ho's cup would never be full.

输入

The first line contains N(1 <= N <= 100000, N is odd) and K(1 <= K <= 100000).
The second line contains N numbers, Little Ho's predicted number d of N rounds.

输出

Output the minimum value of T that makes Little Ho the winner.

样例输入
5 6
3 6 6 2 1
样例输出
4
Hi和Ho在玩一个游戏,游戏有n(n为奇数)个回合,每个回合hi给ho T的水,然后ho投掷一枚k个面的骰子(点数从1到k),记向上的点数为d,若ho杯子里的水<=d那么hi得一分,同时ho将杯子里的水喝完,若>d则ho得一分并喝掉d的水,n个回合之后分多的人获胜。现在知道了每次投掷骰子的n次结果,问T的最小值是多少ho才能获胜。

二分T的值即可,二分区间为[1,k+2)。

代码如下:

/************************************************************************* > 转载请注明出处http://blog.csdn.net/acvcla/article/details/42200345> File Name: xiaozhao.cpp > Author: acvcla > QQ:acvcla@gmail.com  > Mail: acvcla@gmail.com > Created Time: 2014年12月27日 星期一 22时34分13秒 
*************************************************************************/  
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<map>
#include<queue>
#include<set>
#include<vector>
#include<string.h>
#include<cmath>
using namespace std;
const int maxn =1e5;
typedef long long LL;
int d[maxn+10];
bool judge(int T,int n)
{int x1=0,x2=0,rL=T;for(int i=1;i<=n;i++) {if(rL>d[i]) {rL-=d[i];x2++;rL+=T;}else {rL=T;x1++;}}return x1<x2;
}
int solve(int n,int k)
{int L=1,R=k+10;while(L<R) {int M=(L+R)>>1;if(judge(M,n))R=M;else L=M+1;}return R;
}
int main()
{int n,k;while(~scanf("%d%d",&n,&k)) {for(int i=1;i<=n;i++)scanf("%d",d+i);printf("%d\n",solve(n,k));}return 0;
}




题目3 : Divided Product

时间限制: 10000ms
单点时限: 1000ms
内存限制: 256MB

描述

Given two positive integers N and M, please divide N into several integers A1, A2, ..., Ak (k >= 1), so that:

1. 0 < A1 < A2 < ... < Ak;

2. A1 + A2 + ... + Ak = N;

3. A1, A2, ..., Ak are different with each other;

4. The product of them P = A1 * A2 * ... * Ak is a multiple of M;

How many different ways can you achieve this goal?

输入

Two integers N and M. 1 <= N <= 100, 1 <= M <= 50.

输出

Output one integer -- the number of different ways to achieve this goal, module 1,000,000,007.

样例提示

There are 4 different ways to achieve this goal for the sample:

A1=1, A2=2, A3=4;

A1=1, A2=6;

A1=2, A2=5;

A1=3, A2=4.

样例输入
7 2
样例输出
4

给出n和m,要求选一些数(不重复)使得这些数的和为n,乘积为m,n<=100,m<=50,直接搜,开始还想复杂了。orz

代码如下:

/************************************************************************* > 转载请注明出处http://blog.csdn.net/acvcla/article/details/42200345> File Name: xiaozhao.cpp > Author: acvcla > QQ:acvcla@gmail.com  > Mail: acvcla@gmail.com > Created Time: 2014年12月27日 星期一 22时34分13秒 
*************************************************************************/  
#include<cstdio>
#include<iostream>
#include<string>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<queue>
#include<cstdlib>
#include<vector>
#include<set>
#include<map>
#include<stack>
#include<climits>
using namespace std;
const int maxn = 1e5 + 10;
typedef long long ll;
#define rep(i,a,b) for(int i=a;i<=b;i++)
int n,m,ans;void solve(int now_pos,int lft,int lcm){if(lft == 0){if(lcm == m)ans++;return ;}for(int i=now_pos;i<=lft;i++){if(lft>=i)solve(i+1,lft-i,__gcd(lcm*i,m));}
}
int main(){while(~scanf("%d%d",&n,&m)){ans = 0;solve(1,n,1);printf("%d\n",ans);}return 0;
}


这篇关于微软苏州校招笔试 12月27日的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/1130738

相关文章

树莓派5_opencv笔记27:Opencv录制视频(无声音)

今日继续学习树莓派5 8G:(Raspberry Pi,简称RPi或RasPi)  本人所用树莓派5 装载的系统与版本如下:  版本可用命令 (lsb_release -a) 查询: Opencv 与 python 版本如下: 今天就水一篇文章,用树莓派摄像头,Opencv录制一段视频保存在指定目录... 文章提供测试代码讲解,整体代码贴出、测试效果图 目录 阶段一:录制一段

微软正式推出 Spartan 斯巴达浏览器

作为用于替代 IE 浏览器的下一代继任者,微软的 Project Spartan 斯巴达浏览器可算是吊足了玩家们的胃口!如今,在最新的 Windows 10 Build 10049 版本起,它终于正式登场了。 斯巴达浏览器搭载了全新的渲染引擎、新的用户界面并集成了 Cortana 语音助手。功能上新增了稍后阅读列表、阅读视图、F12开发者工具、支持网页注释 (手写涂鸦),可以保存到 O

【秋招笔试】9.07米哈游秋招改编题-三语言题解

🍭 大家好这里是 春秋招笔试突围,一起备战大厂笔试 💻 ACM金牌团队🏅️ | 多次AK大厂笔试 | 大厂实习经历 ✨ 本系列打算持续跟新 春秋招笔试题 👏 感谢大家的订阅➕ 和 喜欢💗 和 手里的小花花🌸 ✨ 笔试合集传送们 -> 🧷春秋招笔试合集 🍒 本专栏已收集 100+ 套笔试题,笔试真题 会在第一时间跟新 🍄 题面描述等均已改编,如果和你笔试题看到的题面描述

两道笔试题

“char a='\72'”是什么意思? 这么理解:\为转义字符,\072转义为一个八进制数072,也就是十进制数的58买一送一,将转义字符对照表也一并贴给你吧:转义字符 意义 ASCII码值(十进制) \a 响铃(BEL) 007 \b 退格(BS) 008 \f 换页(FF) 012 \n 换行(LF) 010 \r 回车(CR) 013 \t 水平制表(HT) 009 \v 垂直制表(VT

华为23年笔试题

消息传输 题目描述 在给定的 m x n (1 <= m, n <= 1000) 网格地图 grid 中,分布着一些信号塔,用于区域间通信。 每个单元格可以有以下三种状态:  值 0 代表空地,无法传递信号;  值 1 代表信号塔 A,在收到消息后,信号塔 A 可以在 1ms 后将信号发送给上下左右四个方向的信号塔; 值 2 代表信号塔 B,在收到消息后,信号塔 B 可以在 2ms

实现的动态规划问题华为笔试题C++实现

秋招刷力扣题,我觉得我对动态规划不是熟练,在此处做总结 动态规划(Dynamic Programming,DP)算法通常用于求解某种具有最优性质的问题。在这类问题中,可能会有许多可行解,每一个解都对应一个值,我们希望找到具有最优值的解。我觉得最大的问题就是对问题的分解,分解后的问题与分解前的问题具有相同的决策机制,将决策机制进行抽象,最终可以得到对应的解; 动态规划中开始介绍的爬楼梯等问题,答

某公司笔试编程题

参加了某公司编程题,这些题都来自牛客网,记录总结吧! 一、蛇形矩阵 题目描述 蛇形矩阵是有1开始的自然数依次排列成的一个上三角矩阵. 接口说明 void GetResult(int Num, int* pResult);输入参数:int Num :输入的正整数N输出参数:int *pResult: 指向放蛇形矩阵的字符串指针指针指向的内存区域保证有效 样例输入: 4

诺瓦星云校招嵌入式面试题及参考答案(100+面试题、10万字长文)

SPI 通信有哪些内核接口? 在嵌入式系统中,SPI(Serial Peripheral Interface,串行外设接口)通信通常涉及以下内核接口: 时钟控制接口:用于控制 SPI 时钟的频率和相位。通过设置时钟寄存器,可以调整 SPI 通信的速度以适应不同的外设需求。数据发送和接收接口:负责将数据从主机发送到从机以及从从机接收数据到主机。这些接口通常包括数据寄存器,用于存储待发

CVTE java web后台实习生笔试+技术一面总结

投的第一份简历,也可以说是第一次写笔试和参加面试。题在前面,总结在最后,努力不骗人。 笔试 题型:20道不定项选择题+2道算法题+1道架构设计题 选择题 选择题出的很全面,因为是不定项选择,一道题就可以考很多知识点。 当时做的时候以为笔试都是这么难,做完实验室同学告诉我这个算比较难的了,而且据我观察可能是跟春招找正式offer的一批难度的题。可能最后过的标准不一样吧。 选项信息量很大,