当前位置: 首页 > wzjs >正文

淘客推广方法广州百度seo排名

淘客推广方法,广州百度seo排名,家具能在什么网站上做,如何写网站代码是什么原因第十四次CCF-CSP认证 卖菜满分思路 买菜满分思路 再卖菜满分题解(差分约束)solution 1(枚举 correct but 超时)solution 2(正解) 卖菜 题目链接 满分思路 就是模拟一下这个调整第二天菜价的过程,其中对于两种只有一个邻居的情况下做出调整&…

第十四次CCF-CSP认证

  • 卖菜
    • 满分思路
  • 买菜
    • 满分思路
  • 再卖菜
    • 满分题解(差分约束)
      • solution 1(枚举 correct but 超时)
      • solution 2(正解)

卖菜

在这里插入图片描述

题目链接

满分思路

就是模拟一下这个调整第二天菜价的过程,其中对于两种只有一个邻居的情况下做出调整,三个for循环分别处理
输入,调整,输出

#include <bits/stdc++.h>
using namespace std;
const int N=1010;
int yes[N],today[N];
int main()
{int n;cin>>n;for(int i=1;i<=n;i++){cin>>yes[i];}for(int i=1;i<=n;i++){if(i==1){today[i]=(yes[i]+yes[i+1])/2;}else if(i==n){today[n]=(yes[n-1]+yes[n])/2;}else{today[i]=(yes[i-1]+yes[i]+yes[i+1])/3;}}for(int i=1;i<=n;i++){cout<<today[i]<<" ";}
}

买菜

在这里插入图片描述
题目链接

满分思路

这题说白了就是两个人都去买菜去了,然后回来把菜装车的时候俩人会聊会天,这样一来一回,问的是 两个人在这个买菜的过程中能聊多久,其实题目已经给出提示了,对于时间段用区间来表示,那么我们是不是只需要找到两个人时间重合的部分就好,对于这个重合部分怎么表示呢
画个图其实就很明了了,这里截一下Y总课上的图示
即:两个区间右端点取一个两者最小值(min)减去左端点取一个最大值

在这里插入图片描述

#include <bits/stdc++.h>
using namespace std;
#define x first
#define y second
typedef pair<int,int> PII;
const int N=2010;
int n;
PII p[N],q[N];
int get(PII a,PII b)
{if(a.y<b.x ||b.y<a.x){return 0;}else{return min(a.y,b.y)-max(a.x,b.x);//对于线段的重合部分取(右端点最小-左端点最大)}
}
int main()
{cin>>n;for(int i=0;i<n;i++){cin>>p[i].x>>p[i].y;}for(int i=0;i<n;i++){cin>>q[i].x>>q[i].y;}int res=0;for(int i=0;i<n;i++){for(int j=0;j<n;j++){res+=get(p[i],q[j]);}}cout<<res<<endl;return 0;
}

再卖菜

第三题是个大模拟 非常麻烦 先跳过了 满分比较艰难
这三题名字?? 我还以为我题目看错了 这出题人???
在这里插入图片描述
题目链接

满分题解(差分约束)

其实这题你仔细看一下,是不是就是第一道题的逆过程,但是往往逆过程是比较难的,这题就是,
知道今天的菜价,问你的是昨天菜价多少,这个其实就需要我们自己找约束条件了,虽然调整的规则一样
但往往你并不能通过这家或几家今天的菜价就能知道这家昨天的菜价,而且这对于所有店都是这样,这其实就是难点所在 等我学完 差分约束 回来补上个人心得

solution 1(枚举 correct but 超时)

#include <iostream>
#include <vector>using namespace std;// 检查当前枚举的第一天菜价序列是否符合第二天菜价的要求
bool check(const vector<int>& day1Prices, const vector<int>& day2Prices) {int n = day1Prices.size();// 检查第一个商店if ((day1Prices[0] + day1Prices[1]) / 2 != day2Prices[0]) {return false;}// 检查中间的商店for (int i = 1; i < n - 1; ++i) {if ((day1Prices[i - 1] + day1Prices[i] + day1Prices[i + 1]) / 3 != day2Prices[i]) {return false;}}// 检查最后一个商店if ((day1Prices[n - 2] + day1Prices[n - 1]) / 2 != day2Prices[n - 1]) {return false;}return true;
}// 枚举并找到符合要求的第一天菜价
vector<int> findDay1Prices(const vector<int>& day2Prices) {int n = day2Prices.size();vector<int> day1Prices(n);// 枚举第一个商店的菜价,从 1 开始for (int firstPrice = 1; ; ++firstPrice) {day1Prices[0] = firstPrice;bool valid = true;// 推导后续商店的菜价for (int i = 1; i < n; ++i) {if (i == 1) {// 第二个商店的菜价根据第一个商店和自身推导day1Prices[i] = 3 * day2Prices[i - 1] - day1Prices[i - 1];if (day1Prices[i] <= 0) {valid = false;break;}} else if (i == n - 1) {// 最后一个商店的菜价根据前一个商店和自身推导day1Prices[i] = 2 * day2Prices[i] - day1Prices[i - 1];if (day1Prices[i] <= 0) {valid = false;break;}} else {// 中间商店的菜价根据相邻商店推导day1Prices[i] = 3 * day2Prices[i] - day1Prices[i - 1] - day1Prices[i - 2];if (day1Prices[i] <= 0) {valid = false;break;}}}if (valid && check(day1Prices, day2Prices)) {return day1Prices;}}return {};
}int main() {int n;cin >> n;vector<int> day2Prices(n);for (int i = 0; i < n; ++i) {cin >> day2Prices[i];}vector<int> day1Prices = findDay1Prices(day2Prices);for (int i = 0; i < n; ++i) {if (i > 0) {cout << " ";}cout << day1Prices[i];}cout << endl;return 0;
}

solution 2(正解)

作者:Tilbur
代码解析

#include <iostream>
#include <cstring>
#include <algorithm>using namespace std;const int N = 310,M=1e5+10;
int h[N], e[M], w[M], ne[M], idx;
int q[N], dist[N];
bool st[N];
int b[N];
int n;void add(int a, int b, int c)  // 添加一条边a->b,边权为c
{e[idx] = b, w[idx] = c, ne[idx] = h[a], h[a] = idx ++ ;
}void spfa()  // 求1号点到n号点的最短路距离
{int hh = 0, tt = 0;memset(dist, -0x3f, sizeof dist);dist[0] = 0;q[tt ++ ] = 0;while (hh != tt){int t = q[hh ++ ];if (hh == N) hh = 0;st[t] = false;for (int i = h[t]; i != -1; i = ne[i]){int j = e[i];if (dist[j] <dist[t] + w[i]){dist[j] = dist[t] + w[i];if (!st[j])     // 如果队列中已存在j,则不需要将j重复插入{q[tt ++ ] = j;if (tt == N) tt = 0;st[j] = true;}}}}
}int main()
{scanf("%d", &n);for (int i = 1; i <= n; i ++ ) scanf("%d",&b[i]);memset(h, -1, sizeof h);for(int i=2;i<n;i++){add(i-2,i+1,3*b[i]);add(i+1,i-2,-3*b[i]-2);}add(0,2,2*b[1]),add(2,0,-2*b[1]-1);add(n-2,n,2*b[n]),add(n,n-2,-2*b[n]-1);for(int i=1;i<=n;i++) add(i-1,i,1);spfa();for(int i=1;i<=n;i++) cout<<dist[i]-dist[i-1]<<' ';return 0;
}
http://www.dtcms.com/wzjs/99931.html

相关文章:

  • wordpress yeti主题以下属于网站seo的内容是
  • 想学编程做网站什么软件可以排名次
  • 微官网制作优化seo系统
  • 吉林网站建设电话宁波网站建设公司
  • 平面设计真实工资谷歌优化seo
  • wordpress建站事项如何做好网络推广
  • 网站建设基础流程图网站流量分析工具
  • 网站建设 小知识网络兼职平台
  • 学校网站建设项目需求报告搜索引擎优化seo专员
  • asp网站建设与设计一个具体网站的seo优化
  • 网站建设知名公司排名推广公众号的9种方法
  • 套模版做网站网络公关
  • 网站建设可研报告百度seo推广优化
  • 泗阳县住房和城乡建设局网站站长之家ip查询工具
  • 空投注册送币网站怎么做如何制定会员营销方案
  • 做网站开发甲方一直要求p图软文营销的概念
  • 建设一个小网站需要多少钱软文推广一般发布在哪些平台
  • 上海待遇好的公司排名排名优化价格
  • 做淘宝链接的网站百度网盘搜索
  • 免费wap网站推荐网络课程
  • 做网站哪家专业百度搜索关键词指数
  • 手机网站布局如何在网上推广自己
  • 专门做折扣的网站超云seo优化
  • 有经验的南昌网站设计华联股份股票
  • 网站的首页怎么做的今日最新足球推荐
  • 网站怎么做下载网页代码网络营销八大目标是什么
  • 贵州做农业网站腾讯nba新闻
  • 做门户网站用什么模板网站服务器搭建与管理
  • 建设的比较好的网站推广公司哪家好
  • 广州 网站开发公司新乡seo公司