第一题 不想加班的HR
#include<iostream>
#include<vector>
using namespace std;
int main() {
int N, x;
vector<int> q;
cin >> N;
for (int i = 0; i < N; i++) {
cin >> x;
q.push_back(x);
}
double ans = 0;
double cur = 0;
for (int i = 0; i < q.size(); i++) {
if (q[i] == 0) {
cur=0;
}
else if (q[i] == 1) {
++cur;
}
else {
cur = (cur + 1) * 0.5;
}
ans += cur;
}
cout << ans << endl;
return 0;
}
第二题 被偷走的箱子
#include<iostream>
using namespace std;
int main() {
int n;
cin >> n;
int R, C, L;
R = 3;
C = n + 1;
L = 3;
long long max = (long long)R * C * L;
long long res = 0;
res = max - n;
cout << res << endl;
return 0;
}
#360实习笔试##360公司##笔试题目#