Microsoft Suzhou School Recruitment Test December 27

Source: Internet
Author: User
Tags rounds cmath

Topic 1:lost in the city time limit:10000msSingle Point time limit:1000msMemory Limit:256MB
Describe

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

Fortunately, Little Hi have a map of the city. The map can be considered as a grid of n*m blocks. Each block was numbered by a pair of integers. The block at the north-west Corner are (1, 1) and the one at the South-east Corner is (N, M). Each block was 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 the surrounding Little hi (Little hi are at the middle block of the 3*3 area), please find out The position of him. Note that Little Hi was disoriented, the upper side of the surrounding area could be actually north side, South side, East Si De or west side.

Input

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 is ' A '-' Z ' or '. '
Line N+2~n+4:each Line 3 characters, describing the area surrounding Little Hi.

Output

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

Sample input
8 8...HSH ..... HSM ..... HST ..... HSPP. Ppghspptppssssss. Mmshhh. Mmsh. Sssshgsh.
Sample output
5 4
give a n*m diagram and a 3*3 diagram that asks you to output the coordinates of the center position of the 3*3 's original image. Direct violence match. Need to note that one can be rotated, after finding the coordinates need to first order, go to a weight good.

The code is as follows:

/************************************************************************* > Reprint Please specify the source <a target=_blank href= " http://blog.csdn.net/acvcla/article/details/42200345 ">http://blog.csdn.net/acvcla/article/details/42200345 </a> > File Name:xiaozhao.cpp > Author:acvcla > Qq:[email protected] > Mail: [em Ail protected] > Created time:2014 December 27 Monday 22:34 13 seconds **************************************************** /#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[2    00];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<< "&LT;&LT;V[I].SECOND&LT;&LT;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;}




Title 2:hiho drinking game time limit:10000msSingle Point time limit:1000msMemory Limit:256MB
Describe

Little Hi and Little Ho is 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 DRI Nks 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 had the most scores wins.

Here comes the problem. If Little Ho can predict the number D of N rounds in the game what's the minimum value of T that makes Little Ho the Winn Er? Assume that's no matter how much water is added, Little Ho's Cup would never be full.

Input

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

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

Sample input
5 63 6 6 2 1
Sample output
4
Hi and Ho are playing a game where the game has n (n odd) rounds, each turn hi to Ho t's water, then Ho throws a K-sided dice (points from 1 to K), notes up the points for D, if the Ho Cup water <=d so hi to a point, while Ho will drink the water in the cup, If >d a point and drank D's water, the number of people after n rounds wins. Now that you know the N-times result of each throw, ask the minimum value of T to how much ho wins.

The value of the binary T can be, and the two intervals are [1,k+2].

The code is as follows:

/************************************************************************* > Reprint Please specify the source <a target=_blank href= " http://blog.csdn.net/acvcla/article/details/42200345 ">http://blog.csdn.net/acvcla/article/details/42200345 </a> > File Name:xiaozhao.cpp > Author:acvcla > Qq:[email protected] > Mail: [EMA Il protected] > Created time:2014 December 27 Monday 22:34 13 seconds ***************************************************** /#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;}



Topic 3:divided Product Time limit:10000msSingle Point time limit:1000msMemory Limit:256MB
Describe

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

1.0 < A1 < A2 < ... < Ak;

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

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

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

How many different ways can I achieve this goal?

Input

integers n and M. 1 <= n <=, 1 <= M <= 50.

Output

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

Sample Hints

There is 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.

Sample input
9 |
Sample output
4

Given N and m, it is required to select some number (do not repeat) so that the sum of these numbers is N, the product is m,n<=100,m<=50, direct search, and began to want to complicate. Orz

The code is as follows:

<span style= "FONT-SIZE:18PX;" >/************************************************************************* > Reprint Please specify the source <a Target=_blank href= "http://blog.csdn.net/acvcla/article/details/41732447" >http://blog.csdn.net/acvcla/article/details/ 41732447</a> > File Name:xiaozhao.cpp > Author:acvcla > qq:[email protected] > M AIL: [email protected] > Created time:2014 December 27 Monday 22:34 13 seconds ********************************************* /#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 n       Ow_pos,int Lft,int LCM) {if (LfT = = 0) { if (LCM = = m) ans++;    return;    } for (int i=now_pos;i<=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;} </span>


Microsoft Suzhou School Recruitment Test December 27

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.