题目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日相关推荐

  1. hihoCoder 1095 HIHO Drinking Game 微软苏州校招笔试 12月27日

    由game规则可以看出,T越大超出d的可能性越大,对小ho越有利,其实我是通过打表才看出来这个单调性的==. 对T进行二分搜索,[0,K+1],因为如果N=1,那么应该有T=K+1,小ho才可以获胜. ...

  2. hihocoder #1103 : Colorful Lecture Note微软苏州校招笔试 1月10日(字符串处理+栈)

    #1103 : Colorful Lecture Note 时间限制:10000ms 单点时限:1000ms 内存限制:256MB 描述 Little Hi is writing an algorit ...

  3. 线上会议丨中国中文信息学会2020学术年会将于12月27日举行

    会议时间 2020年12月27日 北京 会议官网 http://www.cipsc.org.cn/annual2020 扫码进入会议官网 扫码观看直播 特邀报告 按报告时间排序 专题研讨

  4. web实践 例会12月27日

    12月27日 项目进度表: 今日工作: 1.      首先是小组开展例会,确定选题和进行基本功能分析. 2.      确定第一阶段的选做内容为安全性分析. 3.      小组分工如下 a)    ...

  5. 实战 | 深度学习轻松学:如何用可视化界面来部署深度学习模型 转载 2017年12月27日 00:00:00 109 翻译 | AI科技大本营 参与 | 王赫 上个月,我有幸结识了 DeepCogn

    实战 | 深度学习轻松学:如何用可视化界面来部署深度学习模型 转载 2017年12月27日 00:00:00 标签: 109 编辑 删除 翻译 | AI科技大本营 参与 | 王赫 上个月,我有幸结识了 ...

  6. 百度元宇宙产品“希壤”将于12月27日发布

    近日,百度宣布将于12月27日发布元宇宙产品"希壤" ,届时百度 Create 2021(百度 AI 开发者大会)将在希壤 APP 举办. 据介绍,"希壤"AP ...

  7. 三周第三次课(12月27日)

    三周第三次课(12月27日) 3.7 su命令 su 切换用户 whoami id su -aming su aming 切换用户,但是没有切换家目录 su - -c "touch /tmp ...

  8. 电信网通证实台湾地震影响内地访问国际网站(12月27日)

    <iframe align="top" marginwidth="0" marginheight="0" src="http ...

  9. 【历史上的今天】12 月 27 日:第一台计算机背后的女性们;Box 创始人出生;开普勒诞生

    整理 | 王启隆 透过「历史上的今天」,从过去看未来,从现在亦可以改变未来. 今天是 2022 年 12 月 27 日,在 2002 年的今天,南水北调工程开工典礼举行.南水北调是一个可持续发展的工程 ...

  10. 电信网通证实台湾地震影响内地访问国际网站(12月27日) 1

    电信网通证实台湾地震影响内地访问国际网站 http://www.sina.com.cn 2006年12月27日 09:39 东方网   中国国际海底光缆网络 中美六家运营商正在共同建设连接中国和美国的 ...

最新文章

  1. Could not find com.android.support.constraint:constraint-layout的问题解决
  2. ContentType的集中数据编码格式
  3. Codeforces - 914F bitset 维护字符串匹配个数
  4. mysql5.7下载与安装,php5.6与mysql5.7整合
  5. P1848 [USACO12OPEN]Bookshelf G(线段树优化 DP)
  6. 简单绘图软件实现mfc大作业_纸笔书写|可直播可微课可写作业可批改的手写板,快来爱“我”吧...
  7. 事件内核对象 CreateEvent
  8. redis和memcache的对比
  9. 让Office无处不在——Office Web App初体验
  10. 手摸手教你git配置ssh
  11. 第三季-第15课-信号通讯编程
  12. 字节跳动笔试题-前端(互娱)
  13. 激光雷达RPLidar的配置(arduino和rasberrypi)
  14. java贪吃蛇设计答辩PPT_基于Java的贪吃蛇游戏答辩.ppt
  15. 【软件逆向-分析工具】反汇编和反编译工具
  16. c语言程序经过链接以后生成的文件名的后缀为,请多多指教,感激不尽11.C语言程序经过编译以后生成的文件名的后缀为( ).A..c B..obj C..exe D.....
  17. 【nexys3】【verilog】小设计——拆弹游戏
  18. Java中的Set、Map(二叉搜索树篇)
  19. 重磅:2019 前端开发者进阶指南.pdf
  20. 解决方案:Java对DateTime的处理

热门文章

  1. 大数据时代,个人信息安全由谁来保护?
  2. DTU是什么 DTU种类及应用领域分析
  3. 杨令云玩过的那些FC游戏-魔道士的阴谋(二)
  4. pillow库——使用图像类Image
  5. 别人在忙挖矿,京东架构师却悄悄用区块链搞了件大事!
  6. 删除表记录(delete from where )
  7. cesium加载entity图片缩放_Linux 下最棒的 11 个图片查看器 | Linux 中国
  8. 在选用矿物质防火电缆的时候应该注意什么?
  9. 谷歌学术搜索 2019
  10. 计算机怎样更新卡驱动,显卡驱动怎么更新,详细教您怎么更新显卡驱动