第38期:IT培训-当前问题和领先公司的挑战

你好!新的一周-品牌发布商的新版本。这次,在IT公司Accolite接受采访。

顺便说一句,上一期中的问题的答案已经发布,请检查自己和机智。

好吧,走吧!

问题


1. 富人或穷人
一个地方有两种居民:贫穷的人总是说实话,而相反的居民Rich总是在说谎。您遇到两个人A和B。如果A说“ B是穷人”而B说“我们两个人是相反类型”,那么A和B是什么?

传递
: , , , . A B. A B, A «B — », B : « — »?

2. 大理石男孩
一个男孩手里拿着新购买的大理石,去朋友家中的20栋房屋。在他参观的每座房屋中,他都会拿出一半的大理石,然后拿走他朋友的一块大理石,再加上剩下的一块大理石,他从来没有遇到过将剩余的大理石数量分开的问题,最后离开了他有20个朋友的房子,剩下2个弹珠,您能猜出n值吗?

传递
20 «n» . , , , , , . , , , 20 , 2 . «n»?

任务


1. 交换两个半字节
给定一个字节,交换其中的两个半字节。例如,100以一个字节(或8位)表示为01100100。这两个半字节是(0110)和(0100)。如果交换两个半字节,则会得到01000110(十进制为70)。

输入:
第一行包含“ T”,表示测试用例的数量。每个测试用例包含单个正整数X。

输出:
交换半字节后,在每行中打印结果。

约束:示例: 输入:输出:
1 ≤ T ≤ 70
1 ≤ X ≤ 255




2
100
129



70
24

传递
, . , 100 01100100 ( 8 ). — (0110) (0100). , 01000110, 70 .

:
«», . X.

:
.

:
1 ≤ T ≤ 70
1 ≤ X ≤ 255


:
:

2
100
129


:
70
24

2. 计算给定总和的对
给定一个整数数组和一个整数“ K”,找到该数组中总和等于“ K”的元素对的计数。

输入:输入的
第一行包含一个整数T,表示测试用例的数量。然后是T测试用例。每个测试用例由两行组成。每个测试用例的第一行包含2个以空格分隔的整数N和K,分别表示数组的大小和总和。每个测试用例的第二行包含N个以空格分隔的整数,它们表示数组的元素。

输出:
打印数组中总和等于K的元素对的计数。

约束:示例: 输入输出
1<=T<=50
1<=N<=50
1<=K<=50
1<=A[i]<=100




2
4 6
1 5 7 1
4 2
1 1 1 1


2
6

传递
«K», , «K».

:
T, . T . . 2 N K, , . N , , .

:
, .

:
1< = T< = 50
1< = N< = 50
1< = K< = 50
1<=A[i]< = 100


:

2
4 6
1 5 7 1
4 2
1 1 1 1


2
6

3. Trie | (插入和搜索)
Trie is an efficient information retrieval data structure. Use this data structure to store Strings and search strings. Your task is to use TRIE data structure and search the given string A. If found print 1 else 0.

Input:
The first line of input contains a single integer T denoting the number of test cases. Then T test cases follow. Each test case consists of three lines.
First line of each test case consist of a integer N, denoting the number of element in a Trie to be stored.
Second line of each test case consists of N space separated strings denoting the elements to be stored in the trie.
Third line of each test case consists of a String A to be searched in the stored elements.

Output:
Print the respective output in the respective line.

约束:示例: 输入:输出:
1<=T<=20
1<=N<=20




1
8
the a there answer any by bye their
the


1

传递
Trie — . . , TRIE A. , 1, — 0.

:
T, . T . .
N, TRIE, .
N , , , TRIE.
A, .

:
1 0 .

:
1< = T< = 20
1< = N< = 20


:
:

1
8
the a there answer any by bye their
the

:
1

下周将给出任务的答案-有时间解决它。祝好运

All Articles