分析:运算时产生的大数可能会使32位整数溢出,需要使用64位的整数类型more
```cpp
include
include
ifdef DEBUG
include "../comm_headers/debug_helper.h"
else
define DEBUG_OUT(...)
endif继续阅读 »
more
```cpp
include
include
using namespace std;
void hartal(vector & days, int h) {
int n = days.size();
int t = h - 1;
while (t < n) {
int r = t % 7;
if (r != 5 && r != 6)
days[t] = true;
t += h;
}
}继续阅读 »
此题最简单、直观的办法是递归求解:
more
```cpp
vector a; //待登船的汽车长度(单位厘米)数组
int L; //车道长度,单位厘米
//当左右两个车道可用容量分别为left、right时,
//从a[i]到a[n - 1]可登船的最多汽车数
int solve(int i, int left, int right) {
if (i >= a.size() || (a[i] > left && a[i] > right))
return 0;
int l = 0;
int r = 0;
//如果a[i]放在左边
if (a[i] <= left)
l = solve(i 继续阅读 »