DFTY level
获赞
14
粉丝
3
关注
5
看过 TA
156
中国科学院大学
2025
光学工程师
IP属地:甘肃
暂未填写个人简介
私信
关注
能找怎样的工作啊?光学的行吗?
人火炎焱燚:光学工程师可以,看看研究所的工作机会。 民营企业的话看看相机工程师岗位,手机厂小米ov等等,传感器厂豪威等等都有,此外有很多消费电子类公司也有岗,需要多看看。
牛客解忧铺
0 点赞 评论 收藏
分享
#include <functional>#include <iostream>#include <vector>#include <algorithm>using namespace std;int maxProfitWithTwoTransactions(const std::vector<int>& prices) {int n = prices.size();if (n <= 1) return 0;std::vector<int> left(n, 0);std::vector<int> right(n, 0);int minPrice = prices[0];for (int i = 1; i < n; ++i) {minPrice = std::min(minPrice, prices[i]);//状态1:以低价买入left[i] = std::max(left[i - 1], prices[i] - minPrice);//状态2:如果存在利润,则卖出(完成了一次交易),否则持有(状态3)}int maxPrice = prices[n - 1];for (int i = n - 2; i >= 0; --i) {maxPrice = std::max(maxPrice, prices[i]);//状态4:第二次买入right[i] = std::max(right[i + 1], maxPrice - prices[i]);//状态5:如果存在利润,则卖出,否则持有(状态3)}int maxProfit = 0;for (int i = 0; i < n; ++i) {maxProfit = std::max(maxProfit, left[i] + right[i]);}return maxProfit;}int main() {int n;cin >> n;vector<int>price(n, 0);for (int i = 0; i < n; i++) {cin >> price[i];}cout << maxProfitWithTwoTransactions(price);return 0;}这是怎么能运行的??我的注释不一定对,可以忽略
0 点赞 评论 收藏
分享
//求解循环汉诺塔#include <iostream>#include "vector"using namespace std;class Solution {public:vector<long long >fn;vector<long long >gn;Solution(): fn(10000000, 0), gn(10000000, 0) {}long long FN(int n) { //计算fn数组if (n == 1) {fn[1] = 1;return fn[1];} else {if (gn[n - 1] == 0) { //位置不存在fn[n] = ((2 * GN(n - 1) + 1) % 1000000007);return fn[n];} else {fn[n] = ((2 * gn[n - 1] + 1) % 1000000007);return fn[n];}}}long long  GN(int n) { //计算gn数组if (n == 1) {gn[1] = 2;return gn[1];} else {if (gn[n - 1] == 0 && fn[n - 1] == 0) {gn[n] = ((2 * GN(n - 1) + FN(n - 1) + 2) % 1000000007);return gn[n];} else {gn[n] = ((2 * gn[n - 1] + fn[n - 1] + 2) % 1000000007);return gn[n];}}}void LoopHanoi(int n){cout << FN(n) << " " << GN(n) << endl;}};int main() {Solution solution;int n;cin >> n;solution.LoopHanoi(n);}c
新手牛友村
0 点赞 评论 收藏
分享

创作者周榜

更多
关注他的用户也关注了:
牛客网
牛客网在线编程
牛客网题解
牛客企业服务