2024秋招西山居游戏开发SEED种子实习笔试题

本文最后更新于:2024年3月9日 中午

西山居游戏开发SEED种子实习

2024年秋招笔试题目,仅供参考,请大佬多多指教

选择题

逆波兰数,TCP,操作系统FIFO,C语言大小端

填空题

一道LUA脚本写结果,一道并发存储优化题,计算机系统结构里面的知识

算法题

总共三道题目,做出来了两道,最后一道是动态规划,没时间写了

T1

题目

小明对偶数十分痴迷。当小明拿到一个数组,只有当这个数组的和是偶数才会让小明感到开心。 现在小明有一个数组,小明每次可取出数组中的一个数对其进行整除2的操作。问最少需要多少次操作,才能得到使之开心的数组。

输入描述

第一行输入为 T ,表示有 T 组数据, 每组数据第一行输入为 n ,表示数组长度, 接下来 n 个正整数 ai ,表示长度为 n 的数组

输出描述

每组数据输出一个整数,表示最少操作次数

思路

CF原题,容易发现,一个数组的元素和要么是奇数要么是偶数,如果一开始是偶数的话那么我们呢就没有必要进行操作,否则我们必须要改变一个数的奇偶性才能把数组变为好的,因为任意两个数之间是不会相互影响的,所以我们不需要同时对两个数进行操作,我们只需要遍历一遍所有的数,记录每一个数改变奇偶性所需要的最少操作次数,那么答案就是所有最小操作次数中的最小值。

代码

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<map>
#include<queue>
#include<vector>
#include<cmath>
using namespace std;
const int N=53;
int a[N];
int main()
{
int T;
cin>>T;
while(T--)
{
int minnum=0x3f3f3f3f;
int ans=0;
int n;
scanf("%d",&n);
for(int i=1;i<=n;i++)
{
scanf("%d",&a[i]);
ans+=a[i];
int cnt=1;
while((a[i]&1)==((a[i]/2)&1))
cnt++,a[i]/=2;
minnum=min(minnum,cnt);
}
if(ans&1) printf("%d\n",minnum);
else puts("0");
}
return 0;
}

T2

题目

小明发现了一张爷爷留下的字条,但是读不通其中的字意。小明这才想起了爷爷之前教过自己一套加密字符的方法。对于任意一个字符串,按照从头部插入,再从尾部插入的方法以打乱字符串的顺序。 如给定一个字符串” kingsoft “,加密过程如下””->” k “->” ki “->” nki “->” nkig “->” snkig “->” snkigo “->” fsnkigo “->” fsnkigot “小明假定爷爷是用这种方式加密的字符串,请问加密前的字符串是什么

思路

模拟题,类似双指针遍历把字符串取出来就行了

代码

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

string decrypt(string encrypted) {
string result = "";
int len = encrypted.length();
int mid = len / 2 -1;
result+=encrypted[mid];
// cout<<encrypted[mid+1]<<endl;
for (int i = 1; i <= mid; i++) {
result += encrypted[mid+i];
result += encrypted[mid-i];
}
if (len % 2 == 0) {
result += encrypted[len-1];
}
//reverse(result.begin(), result.end());
return result;
}

int main() {
string encrypted = "fsnkigot";
string decrypted = decrypt(encrypted);
cout << decrypted << endl; // 输出 "kingsoft"
return 0;
}

T3

题目

小明手上有两个长度为 n 的数组 a 和 b ,小明对这两个数组的喜欢程度等于 ai * bi 的和 小明有一张操作卡,可以选择一个区间,将 a 中这个区间进行翻转。该操作卡只能使用一次。 问使用操作卡之后,小明对这两个数组的最大喜欢程度是多少。 )

输入描述

第一行,一个整数 n ,(1<n<5000) 第二行, n 个整数,表示数组 a ,(1<ai<10000000)

第二行, n 个整数,表示数组 b ,(1<bi<10000000) )

输出描述

输出一个数,表示小明的最大喜欢程度

输入样例:

3

10 1 1

1 10 1

输出

102

思路

一眼动归,写不完了,润


2024秋招西山居游戏开发SEED种子实习笔试题
https://www.0error.net/2024/01/57110.html
作者
Jiajun Chen
发布于
2024年1月17日
许可协议