网易雷火笔试,大家情况怎么样

前两道AC,第三道70%,第四道瞎写8%,第五道汇编压根不会
第一题
#include <bits/stdc++.h>
using namespace std;
struct window
{
int x;
int y;
int w;
int h;
int id;
window(int x, int y, int w, int h, int id) : x(x), y(y), w(w), h(h), id(id) {}
};
bool inside(int px, int py, window *win)
{
if ((px >= win->x) && (px <= (win->x + win->w)) && (py >= win->y) && (py <= (win->y + win->h)))
return true;
else
return false;
}
int main()
{
int n, m;
cin >> n >> m;
list<window *> l;
for (int i = 0; i < n; i++)
{
int x, y, w, h;
cin >> x >> y >> w >> h;
l.push_front(new window(x, y, w, h, i + 1));
}
for (int i = 0; i < m; i++)
{
bool isClick = false; // 是否点到了
int px, py;
cin >> px >> py;
for (auto it = l.begin(); it != l.end(); it++) // 自顶向下判断点击
{
if (inside(px, py, *it)) // 如果点到了这个窗口
{
isClick = true;
cout << (*it)->id << endl;
if (it != l.begin()) // 如果不是最顶的窗口
{
// cout << "bushizuidin" << endl;
window *wptr = *it;
l.erase(it);
l.push_front(wptr);
}
break;
}
}
if (!isClick)
cout << -1 << endl;
}
return 0;
}
第二题
#include <bits/stdc++.h>
using namespace std;
int r = 0, c = 0;
bool check(int p, int q, vector<int> &nums)
{
for (int i = 0; i < nums.size(); i++)
{
if (nums[i] == p && nums[nums.size() - i - 1]==q)
{
r = log(nums.size()) / log(2) + 1;
c = i + 1;
return true;
}
}
return false;
}
int main()
{
int p, q;
cin >> p >> q;
vector<int> nums;
list<int> temp;
temp.push_back(0);
temp.push_back(1);
for (int i = 0; i < 12; i++)
{
nums.clear();
for (auto it = temp.begin(); it != temp.end(); it++)
{
int n1 = *it;
int n2;
if ((++it) != temp.end())
{
n2 = *it;
}
else
{
break;
}
int n = n1 + n2;
nums.push_back(n);
it = temp.insert(it, n);
}
// for (auto c : nums)
// {
// cout << c << " ";
// }
// cout << endl;
if (check(p, q, nums))
{
cout << r << " " << c << endl;
return 0;
}
}
return 0;
}
第三题(70%)
#include <bits/stdc++.h>
using namespace std;
int x = 0, y = 0;
int lasty = 0;
int maxH = 0;
bool test = false;
int w, xe, ye, xc, yc, px, py;
inline void enter()
{
if (test)
cout << "换行一次" << endl;
x = 0;
if (y != 0)
y += py;
y += (maxH == 0 ? ye : maxH);
maxH = 0;
}
inline void add(int inx, int iny)
{
if (x + px + inx >= w)
{
enter();
add(inx, iny);
}
else
{
maxH = max(maxH, iny);
if (x != 0)
x += px;
x += inx;
}
}
int main()
{
cin >> w >> xe >> ye >> xc >> yc >> px >> py;
vector<vector<int>> image(20, vector<int>(2));
for (int i = 0; i < 20; i++)
{
int inputx, inputy;
cin >> inputx >> inputy;
image[i][0] = inputx;
image[i][1] = inputy;
}
string input;
cin >> input;
string str;
for (int i = 0; i < input.size(); i += 2)
{
stringstream ss;
int h;
ss << input.substr(i, 2);
ss >> hex >> h;
str.push_back((char)h);
}
if (test)
std::cout << endl
<< str << endl;
for (int i = 0; i < str.size(); i++)
{
if (str[i] == '#')
{
if (i == str.size() - 1) // 这是最后一个字符
{
if (test)
cout << "插入英文" << str[i] << endl;
add(xe, ye); // 插入英文字符
continue;
}
else if (str[i + 1] == '0' || (str[i + 1] <= '9' && str[i + 1] >= '2')) // #后面跟着不为1的一个数
{
stringstream ss;
ss << str[i + 1];
int n;
ss >> n;
add(image[n][0], image[n][1]); // 插入表情
i++;
continue;
}
else if (str[i + 1] == '1') // 后面跟着1
{
if (i + 2 >= str.size())
{
add(image[1][0], image[1][1]);
if (test)
cout << "插入表情" << 1 << endl;
i++;
continue;
}
else if (str[i + 2] <= '9' && str[i + 2] >= '0')
{
stringstream ss;
ss << '1' << str[i + 2];
int n;
ss >> n;
if (test)
cout << "插入表情" << n << endl;
add(image[n][0], image[n][1]);
i += 2;
continue;
}
else
{
if (test)
cout << "插入表情" << 1 << endl;
add(image[1][0], image[1][1]);
i++;
continue;
}
}
else if (str[i + 1] == 'r') // 换行
{
enter();
i++;
}
else if (str[i + 1] == '#') // 输出#
{
if (test)
cout << "插入英文"
<< "#" << endl;
add(xe, ye);
i++;
continue;
}
else // 原样输出
{
if (test)
cout << "插入英文" << str[i] << endl;
add(xe, ye);
}
}
else if (str[i] >= 0 && str[i] <= 127)
{
if (test)
cout << "插入英文" << str[i] << endl;
add(xe, ye);
}
else
{
stringstream ss;
ss << str.substr(i, 3);
if (test)
cout << "插入中文 " << ss.str() << x << " " << y << endl;
add(xc, yc);
i += 2;
}
}
if (test)
cout << "maxH:" << maxH << endl;
y += py + maxH;
cout << x - 1 << " " << y - 1 << endl;
return 0;
}

#网易##笔试题目#
全部评论
第四题我也8,怎么想都想不出原因
点赞 回复
分享
发布于 2019-08-04 17:58
第五题多项式拟合,用4阶多项式就可以😂
点赞 回复
分享
发布于 2019-08-04 18:05
小红书
校招火热招聘中
官网直投
第三题压根没看懂。。
点赞 回复
分享
发布于 2019-08-04 18:00
已经凉了,第三题我连题目都看不太懂,那个编码题
点赞 回复
分享
发布于 2019-08-04 18:01
第二道咋做的啊??一直超内存。。
点赞 回复
分享
发布于 2019-08-04 18:10
凉的心服口服😂😂
点赞 回复
分享
发布于 2019-08-04 18:17
求第二题的解题思路
点赞 回复
分享
发布于 2019-08-04 19:26
大佬可以给我说一下怎么看a了没有吗
点赞 回复
分享
发布于 2019-08-04 19:45
好厉害。。。。😲
点赞 回复
分享
发布于 2019-08-04 23:24
我前两道a了,第四道没仔细思考贪心算的8%,第三道碰见utf8编码不会判断英文中文和符号,找了找规律也没写出来。不知道这种程度给过不给。
点赞 回复
分享
发布于 2019-08-05 23:39
大佬啊
点赞 回复
分享
发布于 2019-08-07 13:05
前两道AC,第四题8%,第五题90%,第三题0%,这种题对debug太不友好了,你有过吗
点赞 回复
分享
发布于 2019-08-07 17:33

相关推荐

3 10 评论
分享
牛客网
牛客企业服务