# 蓝桥杯打卡第九天(2.8)

0ms 2023-02-08 18:43:51

## 1.二分法

//力扣提交形式
int search(int* nums, int numsSize, int target){//1 2 9 10 11 66 88 99 100//99
int left = 0, right =numsSize-1, mid;
while (left <= right) {//0 9 //1 9
mid = (left + right) / 2;//4
if (nums[mid] == target) return mid;
else if (nums[mid] < target)  left = mid + 1;
else right = mid - 1;

}
return -1;
}

### 输入描述

1\leq N\leq10^21≤N≤102，1\leq V \leq 2\times10^21≤V≤2×102，1 \leq w_i,v_i,s_i \leq 2\times10^21≤wi​,vi​,si​≤2×102。

### 输出描述

#include<iostream>
#include<algorithm>
using namespace std;
int dp[101][101] = {0};
int main() {
int n, V;
cin >> n >> V;
int w[200] = {0}, v[200] = {0}, s[200] = {0};
for (int i = 1; i <= n; i++)
cin >> w[i] >> v[i] >> s[i];
for (int i = 1; i <= n; i++) {
for (int j = 0; j <= V; j++) {
for (int k = 0; k <= s[i] && k * w[i] <= j; k++) {
dp[i][j] = max(dp[i][j], dp[i - 1][j - k * w[i]] + k * v[i]);
}
}

}
cout << dp[n][V];
}

### 3.题目描述

#include<stdio.h>
int main() {
int f1=1,f2=1,f3=1,f4;
int i;
for (i = 4; i <=20190324; i++) {
f4=(f1+f2+f3)%10000;//求后四位
f1=f2;
f2=f3;
f3=f4;
}
printf("%d",f4);//20190324项正好满足就是对f4;
return 0;
}


...全文
9 回复 打赏 收藏 转发到动态 举报

30,229

• 近7日
• 近30日
• 至今