360 Written Test Questions Review - Development E Paper, a written test for frontend development, including 30 multiple-choice questions and two programming questions.

## Multiple-choice Questions (30 questions)#

Covering various topics, such as databases, calculus, and equations, with a focus on frontend questions in the second half.

## Programming Question 1 - Strong Password Validation (Simple)#

Requirements are roughly as follows:

- Password length should be at least 8 characters.
- Must contain at least one digit, one uppercase letter, one lowercase letter, and one special character (all four are required).

Input Example

```
12_Aaqq12
Password123
PASSWORD_123
PaSS^word
12_Aaqq
```

Output Example

```
Ok
Irregular password
Irregular password
Irregular password
Irregular password
```

## Approach#

In JavaScript, you can use a regular expression, but I'm not familiar with regular expressions. I can only iterate through the string and check, which works fine and passes all test cases. It's a very simple and straightforward approach (not recommended for children to learn).

## Code#

```
#include <iostream>
#include <cstring>
#include <string>
using namespace std;
string str;
bool judge(string s) {
int len = s.length();
if(len < 8) return false;
bool flag[4]; // has digit, uppercase letter, lowercase letter, and special character
memset(flag, false, sizeof(flag));
int cnt = 0;
for(int i = 0; i < len; ++i) {
if(s[i] >= 'A' && s[i] <= 'Z') {
if(!flag[0]) {
flag[0] = true;
++cnt;
}
} else if(s[i] >= 'a' && s[i] <= 'z') {
if(!flag[1]) {
flag[1] = true;
++cnt;
}
} else if(s[i] >= '0' && s[i] <= '9') {
if(!flag[2]) {
flag[2] = true;
++cnt;
}
} else if(!flag[3]) { // special character
flag[3] = true;
++cnt;
}
if(cnt == 4) return true;
}
return false;
}
int main() {
while(cin >> str) {
if(judge(str)) cout << "Ok" << endl;
else cout << "Irregular password" << endl;
}
return 0;
}
```

## Programming Question 2 - Stacked Goods (Web)#

The problem is that the original goods, with dimensions R*C*L, were stacked into a rectangular shape, but were stolen and rearranged into a shape with dimensions (R-2)*(C-1)*(L-2). Given the total number of goods now, calculate the worst-case scenario of how many goods were stolen and output this worst-case value.

Input Description

The input is a number n, representing (R-2)*(C-1)*(L-2) in the problem statement.

Output Description

The output is a number representing the worst-case scenario of how many goods were stolen.

Input Example

```
4
```

Output Example

```
41
```

Hint

For 100% of the data: 1 ≤ n ≤ 10^9

Example Explanation: `R=3,C=5,L=3, 3*5 * 3-(3-2)*(5-1)*(3-2)=41`

## Analysis#

3 2 3 = 18

1 1 1 = 1

17 goods were stolen

4 2 5 = 40

2 1 3 = 6

34 goods were stolen

Steal three rectangular shapes with a volume of `1*(R+2)*(L+2)+ 2*R*C +2*(R+2)*C`

(It can probably be derived mathematically, but I used a brute force approach and then pruned it to pass all test cases)

My brute force solution: Let r, l, and c be the dimensions after the theft, R = r+2, L = l+2, C = c+1. It is obvious that r, l, and c must all be factors of n. Decompose n into prime factors and store all prime factors in m. Iterate through m to get each r, l, and c, and prune along the way. If the product of the current two numbers is already greater than n, skip it.

## Code#

```
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
using namespace std;
typedef long long ll;
int n;
ll ans;
vector<ll> m;
int main() {
cin >> n;
int k = sqrt(n);
for(int i = 1; i <= k; ++i) {
if(n % i == 0) {
m.push_back(i);
m.push_back(n/i);
}
}
sort(m.begin(), m.end());
int len = m.size();
for(int r = 0; r < len; ++r) {
for(int l = 0; l < len; ++l) {
ll t = m[r]*m[l];
if(t > n) continue; // prune
for(int c = 0; c < len; ++c) {
ll nown = t*m[c];
if(nown != n) continue;
ll R = m[r]+2;
ll L = m[l]+1;
ll C = m[c]+2;
ll stole = ll(R*L*C) - nown;
ans = max(ans, stole);
}
}
}
cout << ans << endl;
return 0;
}
```