Skip to main content
  1. Posts/

2017 小米 软件工程师 校招 笔试题 (模拟)

·1 min
Note: This article is available in Chinese only. 本文暂无英文版本。 View original

题意:一串电话号码,每个数字+8取各位后,把每个数字写成对应的大写英文,从"ZERO"和“NINE”,然后打乱字母的顺序。现在给出打乱的字母顺序,问可能的字典序最小的电话号码是是多少(可能有前导0)

思路:分析0..9 每个数字的英文组成。。。然后大概类似解方程。。可以根据字母的个数确定每个数字的个数。。。

然后-8。。。存一下排个序就好了。。。1A

 1#include <cstdio>
 2#include <cstring>
 3#include <iostream>
 4#include <algorithm>
 5#include <vector>
 6#include <queue>
 7#include <set>
 8#include <map>
 9#include <string>
10#include <cmath>
11#include <cstdlib>
12#include <ctime>
13#define fst first
14#define sec second
15#define lson l,m,rt<<1
16#define rson m+1,r,rt<<1|1
17#define ms(a,x) memset(a,x,sizeof(a))
18typedef long long LL;
19#define pi pair < int ,int >
20#define MP make_pair
21using namespace std;
22const double eps = 1E-8;
23const int dx4[4]={1,0,0,-1};
24const int dy4[4]={0,-1,1,0};
25const int inf = 0x3f3f3f3f;
26const int N=1E4+7;
27char st[N];
28int len;
29int a[30];
30int cnt[15]; //0..9数字的个数.
31int main()
32{
33	int T;
34	cin>>T;
35	while (T--)
36	{
37	    scanf("%s",st);
38	    len = strlen(st);
39	    ms(a,0);
40	    ms(cnt,0);
41	    for ( int i = 0 ; i < len ; i++)
42	    {
43		int val = st[i]-'A'+1;
44		a[val]++;
45	    }
46	    cnt[0] = a['Z'-'A'+1];
47	    cnt[6] = a['X'-'A'+1];
48	    cnt[2] = a['W'-'A'+1];
49	    cnt[8] = a['G'-'A'+1];
50	    cnt[4] = a['U'-'A'+1];
51	    cnt[7] = a['S'-'A'+1]-cnt[6];
52	    cnt[5] = a['V'-'A'+1]-cnt[7];
53	    cnt[1] = a['O'-'A'+1]-cnt[0]-cnt[2]-cnt[4];
54	    cnt[3] = a['H'-'A'+1]-cnt[8];
55	    cnt[9] = (a['N'-'A'+1]-cnt[1]-cnt[7])/2;
56	    vector <int>ans;
57	    for ( int i = 0 ; i <= 9 ; i++)
58	    {
59		for ( int j = 1 ; j <= cnt[i] ; j++)
60		{
61		    int val = i-8;
62		    if (val<0) val+=10;
63		    ans.push_back(val);
64		}
65	    }
66	    sort(ans.begin(),ans.end());
67	    int siz = ans.size();
68	    for ( int i  = 0 ; i < siz; i ++) printf("%d",ans[i]);
69	}
70  #ifndef ONLINE_JUDGE
71  fclose(stdin);
72  #endif
73    return 0;
74}

Related

hdu 5835 || ccpc 2016 网络赛 1004 Danganronpa (模拟)

·2 mins
hdu 5835 题目链接 题意:n种礼物,每种a[i]个。现在有无穷个小朋友排成一排,分给每个人一个“普通”的礼物,一个“昂贵”的礼物(哪个普通哪个昂贵是自己定的,或者说,任意的) 要求是相邻的小朋友的普通的礼物不能是同一种。现在问最多能给多少小朋友分礼物。。。

bzoj1603: [Usaco2008 Oct]打谷机 (纱布题)

·2 mins
# Time Limit: 5 Sec Memory Limit: 64 MB Submit: 774 Solved: 593 [Submit][Status][Discuss] Description # Farmer John有一个过时的打谷机(收割小麦),它需要带子来带动。发动机驱动轮1总是顺时针旋转的,用来带动转轮2,转轮2来带动转轮3,等等。一共有n(2<=n<=1000)个转轮(n-1条带子)。上面的图解描述了转轮的两种连接方式,第一种方式使得两个轮子旋转的方向相同,第二种则相反。 给出一串带子的信息: *Si—驱动轮 *Di—被动轮 *Ci—连接的类型(0=直接连接,1=交叉连接) 不幸的是,列出的信息是随即的。 作为样例,考虑上面的图解,n=4,转轮1是驱动轮,可以得知最后转轮4是逆时针旋转的。

hdu 5611 || BC #69 div2 1002 Baby Ming and phone number

·2 mins
http://acm.hdu.edu.cn/showproblem.php?pid=5611 题意:给出n个电话号码(长度为11的字符串),满足特殊条件的价格为a,否则为b.特殊条件为最后5位数字一样,最后5位严格递增或者严格递减,最后8位是一个1980年1月一日到2016年12月31日的合法日期。问最后的价值。