首页 > 爱奇艺笔试-非科班考生碰上非科班考题

爱奇艺笔试-非科班考生碰上非科班考题

AK代码。还行。
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n;
	while(cin >> n) {
		int cnt = 0;
		while(n) {
			cnt += n/5;
			n /= 5;
		}
		cout << cnt << endl;
	}
	return 0;
}


#include <bits/stdc++.h>
using namespace std;

int main()
{
	string s;
	while (cin >> s) {
		unordered_map<long long, unordered_set<long long>> vis;
		long long x = 0, y = 0;
		bool find = false;
		vis[0].insert(0);
		for (int i = 0; i < s.size(); i++) {
			if (s[i] == 'E') {
				x += 1;
			}
			else if (s[i] == 'W') {
				x -= 1;
			}
			else if (s[i] == 'N') {
				y += 1;
			}
			else if(s[i] == 'S'){
				y -= 1;
			}
			if (vis.find(x) != vis.end() && vis[x].find(y) != vis[x].end()) {
				find = true;
				break;
			}
			vis[x].insert(y);
		}
		if (find) {
			cout << "True" << endl;
		}
		else {
			cout << "False" << endl;
		}
	}
	return 0;
}

#include <bits/stdc++.h>
using namespace std;
bool pairChar(char a, char b) {
	if(a == '(' && b == ')') return true;
	if(a == '{' && b == '}') return true;
	if(a == '[' && b == ']') return true;
	return false;
}
int main()
{
	string s;
	while(cin >> s) {
		stack<char> stack;
		bool valid = true;
		for(int i = 0; i < s.size(); i++) {
			if(s[i] == '(' || s[i] == '{' || s[i] == '[') {
				stack.push(s[i]);
			} else {
				if(!stack.empty() && pairChar(stack.top(), s[i])) {
					stack.pop();
				} else {
					valid = false;
					break;
				}
			}
		}
		if(!valid || !stack.empty()) {
			cout << "False" << endl;
		} else {
			cout << "True" << endl;
		}
	}
	return 0;
}

最后竟然是卫星定位的题,算是半个老本行了,答得磕磕巴巴,四星定位、伪距、PDOP、双频啥的瞎比比一通,爱奇艺有点搞啊,真不招人了?



全部评论

(0) 回帖
加载中...
话题 回帖

推荐话题

相关热帖

近期热帖

历年真题 真题热练榜 24小时
技术(软件)/信息技术类
查看全部

近期精华帖

热门推荐