【PAT - 甲级 - 1018】Public Bike Management (带权最短路,多条最短路中加条件,DFS)

题干:

链接:https://www.nowcoder.com/questionTerminal/4b20ed271e864f06ab77a984e71c090f
来源:牛客网
There is a public bike service in Hangzhou City which provides great convenience to the tourists from all over the world. One may rent a bike at any station and return it to any other stations in the city.
The Public Bike Management Center (PBMC) keeps monitoring the real-time capacity of all the stations. A station is said to be in perfect condition if it is exactly half-full. If a station is full or empty, PBMC will collect or send bikes to adjust the condition of that station to perfect. And more, all the stations on the way will be adjusted as well.
When a problem station is reported, PBMC will always choose the shortest path to reach that station. If there are more than one shortest path, the one that requires the least number of bikes sent from PBMC will be chosen.

Figure 1
Figure 1 illustrates an example. The stations are represented by vertices and the roads correspond to the edges. The number on an edge is the time taken to reach one end station from another. The number written inside a vertex S is the current number of bikes stored at S. Given that the maximum capacity of each station is 10. To solve the problem at S3 , we have 2 different shortest paths:
1. PBMC -> S1 -> S3 . In this case, 4 bikes must be sent from PBMC, because we can collect 1 bike from S1 and then take 5 bikes to S3 , so that both stations will be in perfect conditions.
2. PBMC -> S2 -> S3 . This path requires the same time as path 1, but only 3 bikes sent from PBMC and hence is the one that will be chosen.

输入描述:

Each input file contains one test case.  For each case, the first line contains 4 numbers: Cmax (<= 100), always an even number, is the maximum capacity of each station; N (<= 500), the total number of stations; Sp, the index of the problem station (the stations are numbered from 1 to N, and PBMC is represented by the vertex 0); and M, the number of roads.  The second line contains N non-negative numbers Ci (i=1,...N) where each  Ci is the current number of bikes at Si respectively.  Then M lines follow, each contains 3 numbers: Si, Sj, and Tij which describe the time Tij taken to move betwen stations Si and Sj.  All the numbers in a line are separated by a space.


 

输出描述:

For each test case, print your results in one line.  First output the number of bikes that PBMC must send.  Then after one space, output the path in the format: 0->S1->...->Sp.  Finally after another space, output the number of bikes that we must take back to PBMC after the condition of Sp is adjusted to perfect.
Note that if such a path is not unique, output the one that requires minimum number of bikes that we must take back to PBMC.  The judge's data guarantee that such a path is unique.

示例1

输入

10 3 3 5
6 7 0
0 1 1
0 2 1
0 3 3
1 3 1
2 3 1

输出

3 0->2->3 0

再给一组样例:
100 6 1 15
78 54 0 37 36 82
0 1 7
0 2 4
0 3 7
0 4 7
0 5 2
1 2 9
1 3 1
1 4 2
1 5 5
2 3 1
2 4 2
2 5 7
3 4 4
3 5 7
4 5 7
对应输出应该为:
46 0->2->3->1 28

题目大意:每个自行车车站的最大容量为一个偶数cmax,如果一个车站里面自行车的数量恰好为cmax / 2,那么称处于完美状态。如果一个车站容量是满的或者空的,控制中心(处于结点0处)就会携带或者从路上收集一定数量的自行车前往该车站,一路上会让所有的车站沿途都达到完美。现在给出cmax,车站的数量n,问题车站sp,m条边,还有距离,求最短路径。如果最短路径有多个,求能带的最少的自行车数目的那条。如果还是有很多条不同的路,那么就找一个从车站带回的自行车数目最少的。带回的时候是不调整的

解题报告:

   这题解法多种多样,此处列举二三。

AC代码1:(双dfs)

#include<bits/stdc++.h>using namespace std;
const int INF = 0x3f3f3f3f;
int maze[505][505];
int val[505],dis[505];
bool vis[505];
int ans;
int c,n,s,m; 
void Dijkstra() {memset(dis,INF,sizeof dis);memset(vis,0,sizeof vis);dis[0]=0;int all = n+1,minw,minv;while(all--) {minw = INF;for(int i = 0; i<=n; i++) {if(vis[i]) continue;if(dis[i] < minw) {minw = dis[i];minv = i;}}vis[minv] = 1;for(int i = 0; i<=n; i++) {if(vis[i] || maze[minv][i] == INF) continue;dis[i] = min(dis[i],dis[minv] + maze[minv][i]);}}
}
void dfs(int x,int res) {if(res < 0) return ;if(x == s) {ans = min(ans,res);return ;}for(int i = 0; i<=n; i++) {if(maze[x][i] == INF) continue;if(dis[i] == dis[x] + maze[x][i]) dfs(i,res - (c-val[i]));}
}
bool Dfs(int x, int y, int z) {if (x==0) {if (y == z) {printf("0");return 1;} else return 0;}for (int i = 0; i <= n; i++) {if (maze[x][i] == -1) continue;if (dis[x] == dis[i] + maze[x][i]) {if (Dfs(i, y + c - val[x], z)) {printf("->%d", x);return 1;}}}return 0;
}int main() {int a,b,w;cin>>c>>n>>s>>m;c>>=1;for(int i = 1; i<=n; i++) scanf("%d",val+i);memset(maze,INF, sizeof maze);for(int i = 1; i<=m; i++) {scanf("%d%d%d",&a,&b,&w);if(w < maze[a][b]) maze[a][b] = maze[b][a] = w;}Dijkstra();int l = 0,r = n*c;int mid = (l+r)/2;while(l < r) {mid = (l+r)/2;ans = INF;dfs(0,mid);if(ans == INF) l = mid+1;else r=mid;}printf("%d ",l);dfs(0,l);Dfs(s,ans,l);printf(" %d\n", ans);return 0 ;
}

此法先用邻接矩阵存图,然后跑Dijkstra求出1号点到各点的最短路,然后二分答案从中心带出多少辆车,顺便求出需要带回多少辆车,因为数据保证有且唯一正确的路径,所以倒序找到路径,一定能找到、、、、总之不是很好理解。

 

AC代码2:

#include<bits/stdc++.h>
using namespace std;
const int inf = 0x3f3f3f3f;
int cmax, n, sp, m;
int minNeed = inf, minBack = inf;
int e[510][510], dis[510], weight[510];
bool vis[510];
vector<int> pre[510];
vector<int> path, temppath;
void dfs(int v) {temppath.push_back(v);if(v == 0) {int need = 0, back = 0;for(int i = temppath.size() - 1; i >= 0; i--) {int id = temppath[i];if(weight[id] > 0) {back += weight[id];} else {if(back > (0 - weight[id])) {back += weight[id];} else {need += ((0 - weight[id]) - back);back = 0;}}}if(need < minNeed) {minNeed = need;minBack = back;path = temppath;} else if(need == minNeed && back < minBack) {minBack = back;path = temppath;}temppath.pop_back();return ;}for(int i = 0; i < pre[v].size(); i++)dfs(pre[v][i]);temppath.pop_back();
}
int main() {memset(e,inf,sizeof e);memset(dis,inf,sizeof dis);scanf("%d%d%d%d", &cmax, &n, &sp, &m);for(int i = 1; i <= n; i++) {scanf("%d", &weight[i]);weight[i] = weight[i] - cmax / 2;}for(int i = 0; i < m; i++) {int a, b;scanf("%d%d", &a, &b);scanf("%d", &e[a][b]);e[b][a] = e[a][b];}dis[0] = 0;for(int i = 0; i <= n; i++) {int u = -1, minn = inf;for(int j = 0; j <= n; j++) {if(vis[j] == false && dis[j] < minn) {u = j;minn = dis[j];}}if(u == -1) break;vis[u] = true;for(int v = 0; v <= n; v++) {if(vis[v] == false && e[u][v] != inf) {if(dis[v] > dis[u] + e[u][v]) {dis[v] = dis[u] + e[u][v];pre[v].clear();pre[v].push_back(u);} else if(dis[v] == dis[u] + e[u][v]) {pre[v].push_back(u);}}}}dfs(sp);printf("%d 0", minNeed);for(int i = path.size() - 2; i >= 0; i--)printf("->%d", path[i]);printf(" %d", minBack);return 0;
}

这种方法相对来说较好理解,就是先dijkstra跑出最短路条数并且记录路径,然后dfs搜索出最优路径

分析:Dijkstra + DFS。如果只有Dijkstra是不可以的,因为minNeed和minBack在路径上的传递不满足最优子结构,不是简单的相加的过程,只有在所有路径都确定了之后才能去选择最小的need和最小的back。
Dijkstra求最短路径,dfs求minNeed和minBack和path,dfs的时候模拟一遍需要调整的过程,求出最后得到的need和back,与minNeed和minBack比较然后根据情况更新path,最后输出minNeed path 和 minBack,记得path是从最后一个结点一直到第一个结点的,所以要倒着输出~

 

AC代码3:

这个更不知道为什么了。。甚至回溯都没看懂,为啥注释那一行加上,for中那一行去掉,就不对了

#include <bits/stdc++.h>
using namespace std;
const int maxn=500+5,INF=1e9;
int cap,n,sp,m,bike[maxn],cost[maxn][maxn];
vector<int> G[maxn],anspath,curpath;
int minsend=INF,minback=INF,mincost=INF,vis[maxn];
void dfs(int cur,int cursend,int curback,int curcost){vis[cur]=1;curpath.push_back(cur);if(curcost>mincost) return ;if(cur==sp){if(curcost<mincost){mincost=curcost;minsend=cursend;minback=curback;anspath=curpath;return ;}if(curcost==mincost&&cursend<minsend){mincost=curcost;minsend=cursend;minback=curback;anspath=curpath;return ;        }if(curcost==mincost&&cursend==minsend&&curback<minback){mincost=curcost;minsend=cursend;minback=curback;anspath=curpath;return ;}return ;}for(int i=0;i<G[cur].size();++i){int v=G[cur][i];if(!vis[v]){if(bike[v]+curback<cap/2) dfs(v,cursend+cap/2-bike[v]-curback,0,curcost+cost[cur][v]);else dfs(v,cursend,curback+bike[v]-cap/2,curcost+cost[cur][v]);vis[v]=0;curpath.pop_back();            }}
//    vis[cur]=0;curpath.pop_back();    
}
int main(){scanf("%d %d %d %d",&cap,&n,&sp,&m);for(int i=1;i<=n;++i) scanf("%d",&bike[i]);for(int i=1,x,y,z;i<=m;++i){scanf("%d %d %d",&x,&y,&z);G[x].push_back(y);G[y].push_back(x);cost[x][y]=z;cost[y][x]=z;        }dfs(0,0,0,0);printf("%d ",minsend);for(int i=0;i<anspath.size();++i)if(i==0) printf("%d",anspath[i]);else printf("->%d",anspath[i]);    printf(" %d\n",minback);return 0;
} 

(更新:知道为什么了,,因为前面有的地方就return了,就没执行popback这行了,样例都过不了,所以保险起见,还是改成for循环中vis=1和vis=0吧,改成这样:)

void dfs(int cur,int cursend,int curback,int curcost){
//    vis[cur]=1;curpath.push_back(cur);if(curcost>mincost) return ;if(cur==sp){if(curcost<mincost){mincost=curcost;minsend=cursend;minback=curback;anspath=curpath;return ;}if(curcost==mincost&&cursend<minsend){mincost=curcost;minsend=cursend;minback=curback;anspath=curpath;return ;      }if(curcost==mincost&&cursend==minsend&&curback<minback){mincost=curcost;minsend=cursend;minback=curback;anspath=curpath;return ;}return ;}for(int i=0;i<G[cur].size();++i){int v=G[cur][i];if(!vis[v]){vis[v] = 1;curpath.push_back(v);if(bike[v]+curback<cap/2) dfs(v,cursend+cap/2-bike[v]-curback,0,curcost+cost[cur][v]);else dfs(v,cursend,curback+bike[v]-cap/2,curcost+cost[cur][v]);vis[v]=0;curpath.pop_back();          }}
//    vis[cur]=0;curpath.pop_back();  
}

并且在主函数的dfs前: 

    vis[0]=1;curpath.push_back(0); 

 

AC代码4:

但是感觉还是复杂度有点高,并且不稳定,我给他改了一下,变成简单易懂的了。。

#include<bits/stdc++.h>
using namespace std;
const int maxn=500+5,INF=0x3f3f3f3f;
int cap,n,sp,m,bike[maxn],cost[maxn][maxn];
vector<int> G[maxn],anspath,curpath;
int minsend=INF,minback=INF,mincost=INF,vis[maxn];
int dis[maxn];
void Dijkstra() {int all = n+1;bool visit[maxn] = {0};memset(dis,INF,sizeof dis);dis[0]=0;while(all--) {int minv,minw = INF;for(int i = 0; i<=n; i++) {if(visit[i]==0 && dis[i] < minw) minw=dis[i],minv=i;}visit[minv]=1;for(int i = 0; i<G[minv].size(); i++) {int now = G[minv][i];if(visit[now] == 0 && dis[now] > dis[minv] + cost[minv][now]) dis[now] = dis[minv] + cost[minv][now];}}
}
void dfs(int cur,int cursend,int curback,int curcost){if(curcost>mincost) return ;if(cur==sp){if(cursend<minsend){minsend=cursend;minback=curback;anspath=curpath;return ;	   }if(cursend==minsend&&curback<minback){minsend=cursend;minback=curback;anspath=curpath;return ;}return ;}for(int i=0;i<G[cur].size();i++){int v=G[cur][i];if(!vis[v]){vis[v] = 1;curpath.push_back(v);if(bike[v]+curback<cap/2) dfs(v,cursend+cap/2-bike[v]-curback,0,curcost+cost[cur][v]);else dfs(v,cursend,curback+bike[v]-cap/2,curcost+cost[cur][v]);vis[v]=0;curpath.pop_back();}}
}
int main(){scanf("%d %d %d %d",&cap,&n,&sp,&m);for(int i=1;i<=n;++i) scanf("%d",&bike[i]);for(int i=1,x,y,z;i<=m;++i){scanf("%d %d %d",&x,&y,&z);G[x].push_back(y);G[y].push_back(x);cost[x][y]=z;cost[y][x]=z;	   }Dijkstra();mincost = dis[sp];vis[0]=1;curpath.push_back(0); dfs(0,0,0,0);printf("%d ",minsend);for(int i=0;i<anspath.size();++i)if(i==0) printf("%d",anspath[i]);else printf("->%d",anspath[i]);   printf(" %d\n",minback);return 0;
}

AC代码5:

还算能看懂的:(其实和AC代码3差不多、、)

#include<iostream>
#include<fstream>
#include<vector>
using namespace std;
#define MAX 505
#define INF 10000int cap,N,sp,M;
int vex;
int dist[MAX][MAX];
int bike[MAX];
#define PF cap/2vector<int> curpath;
vector<int> shortpath;
int minsend=INF,minback=INF;
int minlen=INF;
int cursend=0,curback=0;
int curlen=0;
bool visit[MAX]= {0};void dfs(int cur) {if(curlen>minlen)return;if(cur==sp) {//到达目标点,看是否最优if(curlen<minlen) {minlen=curlen;minsend=cursend;minback=curback;shortpath=curpath;} else if(curlen==minlen) {if(cursend<minsend||(cursend==minsend&&curback<minback)) {minsend=cursend;minback=curback;shortpath=curpath;}}return;}for(int i=1; i<vex; i++) {if(visit[i]==true||dist[cur][i]==INF)continue;int lastsend=cursend;int lastback=curback;//计算到达当前点的send和back数if(bike[i]+curback<PF) {cursend+=PF-bike[i]-curback;curback=0;} else {curback=bike[i]+curback-PF;}visit[i]=true;curpath.push_back(i);curlen+=dist[cur][i];dfs(i);curpath.pop_back();visit[i]=false;curlen-=dist[cur][i];cursend=lastsend;curback=lastback;}
}
int main() {cin>>cap>>N>>sp>>M;//初始化,距离置为INFvex=N+1;for(int i=0; i<vex; i++) {for(int j=0; j<vex; j++) {dist[i][j]=dist[j][i]=INF;}}for(int i=1; i<vex; i++) cin>>bike[i];for(int k=0; k<M; k++) {int i,j;cin>>i>>j>>dist[i][j];dist[j][i]=dist[i][j];}dfs(0);printf("%d 0",minsend);for(int i=0; i<shortpath.size(); i++) {printf("->%d",shortpath[i]);}printf(" %d",minback);return 0;
}

 

ps:wjh大佬写了个Dijkstra不加dfs,有点小问题但是也AC了,但是这个代码也告诉我们为什么这题不能用Dijkstra而应该加上dfs。

#include<bits/stdc++.h>
using namespace std;
struct node {int id;int d;int next;
} side[12000];
int head[1200];
int dis[1200];
int book[1200];
int cm,n,m,sp,cmax;
int num[1000];
int f[1000];
int dc[1000],tz[1000];
int cnt=0;
void init() {for(int i=0; i<=800; i++) {f[i]=i;}memset(dc,0x3f3f3f3f,sizeof(dc));memset(tz,0,sizeof(tz));memset(num,0,sizeof(num));memset(head,-1,sizeof(head));memset(dis,0x3f3f3f3f,sizeof(dis));memset(book,0,sizeof(book));cnt=0;
}
void add(int x,int y,int d) {side[cnt].id=y;side[cnt].d=d;side[cnt].next=head[x];head[x]=cnt++;
}
struct nod {int id;int d;nod() {}nod(int id,int d):id(id),d(d) {}friend bool operator<(nod a,nod b) {return a.d>b.d;}
};
void printpath(int x) {if(f[x]==x) {printf("0");return;} else {printpath(f[x]);printf("->%d",x);}
}
void dijkstra(int sx,int ex) {priority_queue<nod> q;q.push(nod(sx,0));dis[sx]=0;dc[sx]=0;while(!q.empty()) {nod nn=q.top();q.pop();if(book[nn.id])continue;book[nn.id]=1;if(nn.id==ex)break;for(int i=head[nn.id]; i!=-1; i=side[i].next) {int ty=side[i].id;if(dis[ty]>dis[nn.id]+side[i].d) {dis[ty]=dis[nn.id]+side[i].d;f[ty]=nn.id;if(cm>=num[ty]+tz[nn.id]) {tz[ty]=0;dc[ty]=dc[nn.id]+cm-(num[ty]+tz[nn.id]);} else {dc[ty]=dc[nn.id];tz[ty]=tz[nn.id]+num[ty]-cm;}q.push(nod(ty,dis[ty]));} else if(dis[ty]==dis[nn.id]+side[i].d) {
//				&&dc[ty]<if(cm>=num[ty]+tz[nn.id]) {if(dc[ty]>dc[nn.id]+cm-num[ty]+tz[nn.id]) {tz[ty]=0;dc[ty]=dc[nn.id]+cm-(num[ty]+tz[nn.id]);f[ty]=nn.id;q.push(nod(ty,dis[ty]));}} else {if(dc[ty]>dc[nn.id]) {dc[ty]=dc[nn.id];tz[ty]=tz[nn.id]+num[ty]-cm;f[ty]=nn.id;q.push(nod(ty,dis[ty]));}}} }}cout<<dc[ex]<<" ";printpath(ex);cout<<" "<<tz[ex]<<endl;
}int main() {scanf("%d%d%d%d",&cmax,&n,&sp,&m);cm=cmax/2;int x,y,w;init();//初始化for(int i=1; i<=n; i++) {scanf("%d",&num[i]);}for(int i=0; i<m; i++) {scanf("%d%d%d",&x,&y,&w);add(x,y,w);add(y,x,w);}dijkstra(0,sp);return 0;
}

总结:

  这题不能用Dijkstra啊,因为在贪心的过程中只是dis数组是有效信息(顶多依据题意加一个最短路条数),其他的还有很多信息都丢失了。比如这组样例,其中Cmax=10(也就是要凑5),第一个圈为PBMC,每个圈中的数字代表自行车数;

如果最后一个圈内数字是0,那么为①路径,如果圈内数字是5,那么为②路径。所以具体哪个路径还是要搜索去看,而不能DIjkstra就定终生。因为比如:在A这个点的时候,是①和②两条路径择优选择了,没问题,如果到此为止了肯定我们要②路径。但是问题就在于,对于后面的点,未必会继承这一特性啊!(以后自己造样例的时候也可以这样造,造一个样例来说明不满足“可继承”特性的)换句话说这题的条件和需要加的限制很多,并无法证明满足无后效性,所以会Dijkstra丢掉很多信息,而应该用dfs,搜索每一条路径,这样就不会有漏下的情况。

  读到这里,我也是理解了前面那个“分析”中说的不能只用DIjkstra的原因。

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/441514.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

【牛客 - 181C】序列(前缀和,二分,可用set维护)(有坑)

题干&#xff1a; 小a有n个数&#xff0c;他想把他们划分为连续的权值相等的k段&#xff0c;但他不知道这是否可行。 每个数都必须被划分 这个问题对他来说太难了&#xff0c;于是他把这个问题丢给了你。 输入描述: 第一行为两个整数n,q&#xff0c;分别表示序列长度和询问…

【CodeForces - 122B 】Lucky Substring (字符串,水题)

题干&#xff1a; Petya loves lucky numbers. Everybody knows that lucky numbers are positive integers whose decimal representation contains only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. One day Petya was …

*【CodeForces - 122D】Lucky Transformation(字符串问题,思维剪枝,优化,有坑,需注意的问题if的层次总结)

题干&#xff1a; Petya loves lucky numbers. Everybody knows that lucky numbers are positive integers whose decimal representation contains only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. Petya has a number…

c/c++,字符,字符串,各种方式读入与对空格,回车的处理

#include<iostream> #include<string> using namespace std; int main() {char a[50],b[50],charr;//经测试&#xff0c;cin读入字符串&#xff0c;会识别空格和回车为截止&#xff0c;并且不会吞掉&#xff0c;//只是每次读的时候会从第一个不为空格/回车的字符开…

【CodeForces - 357D】Xenia and Hamming (字符串问题,数论,思维)

题干&#xff1a; Xenia is an amateur programmer. Today on the IT lesson she learned about the Hamming distance. The Hamming distance between two strings s  s1s2... sn and t  t1t2... tn of equal length n is value . Record [si ≠ ti] is the Iverson n…

【牛客 - 181D】小叶的巡查(树的直径,数学)

题干&#xff1a; 8102年&#xff0c;牛客系列竞赛空前繁荣。为了更好地管理竞赛&#xff0c;小叶决定巡查于各大城市之间&#xff0c;体察民情。所以&#xff0c;从一个城市马不停蹄地到另一个城市成了小叶最常做的事情。小叶有一个钱袋&#xff0c;用于存放往来城市间的路费…

【蓝桥杯 - 练习】k倍区间(思维,数组)

题干&#xff1a; http://lx.lanqiao.cn/problem.page?gpidT444 问题描述 给定一个长度为N的数列&#xff0c;A1, A2, ... AN&#xff0c;如果其中一段连续的子序列Ai, Ai1, ... Aj(i < j)之和是K的倍数&#xff0c;我们就称这个区间[i, j]是K倍区间。   你能求出数列中…

【 HDU - 1525 】Euclid's Game(较难找规律,玄学博弈,分析必败点必胜点)

题干&#xff1a; Two players, Stan and Ollie, play, starting with two natural numbers. Stan, the first player, subtracts any positive multiple of the lesser of the two numbers from the greater of the two numbers, provided that the resulting number must be…

【CodeForces - 569A】Music (数学公式化简,模拟追及问题)

题干&#xff1a; Little Lesha loves listening to music via his smartphone. But the smartphone doesnt have much memory, so Lesha listens to his favorite songs in a well-known social network InTalk. Unfortunately, internet is not that fast in the city of E…

【CodeForces - 569B】Inventory (标记,乱搞)

题干&#xff1a; Companies always have a lot of equipment, furniture and other things. All of them should be tracked. To do this, there is an inventory number assigned with each item. It is much easier to create a database by using those numbers and keep …

【CodeForces - 371D】Vessels(思维,元素合并,并查集)

题干&#xff1a; There is a system of n vessels arranged one above the other as shown in the figure below. Assume that the vessels are numbered from 1 to n, in the order from the highest to the lowest, the volume of the i-th vessel is ai liters. Initially…

【UVA - 10891 Game of Sum 】【HRBUST - 1622】 Alice and Bob (区间dp,博弈问题)

题干&#xff1a; 有一个长度为N的整数序列&#xff0c;Alice和Bob轮流取数&#xff0c;Alice先取。每次玩家只能从左端或者右端 取一个或多个数&#xff0c;但不能两端都取。所有数都被取走后游戏结束&#xff0c;然后统计每个人取走的所有数之和&#xff0c; 作为各自的得分…

code iban 是有什么组成_EAN-128码和Code-128码的区别

什么是Code-128码&#xff1f;什么是EAN-128码&#xff1f;二者之间有什么区别&#xff1f;接下来小编就给大家解除心中的疑惑。Code-128码是一种高密度的条形码&#xff0c;可表示从 ASCII 0 到ASCII 127 共128个字符&#xff08;其中包含数字&#xff0c;字母&#xff0c;符号…

计算机中丢失setupxml.dll,Win7电脑安装VideoStudio Pro X6显示丢失SetupXML.dll文件怎么解决...

最近有win7系统用户在电脑安装VideoStudio Pro X6软件的时候&#xff0c;突然出现错误的提示&#xff0c;显示无法启动此程序&#xff0c;因为计算机中丢失SetupXML.dll。尝试重新安装该程序来解决此问题&#xff0c;要怎么办呢&#xff0c;下面给大家讲解一下Win7电脑安装软件…

怎么p出模糊的照片_36. 盲去卷积 - 更加实用的图像去模糊方法

本文同步发表在我的微信公众号和知乎专栏“计算摄影学”&#xff0c;欢迎扫码关注&#xff0c;上一篇文章35. 去卷积&#xff1a;怎么把模糊的图像变清晰&#xff1f;吸引了很多朋友的关注。在这篇文章里面&#xff0c;我给大家讲了一种叫做“非盲去卷积”的方法&#xff0c;当…

【CodeForces - 1038A 】Equality (思维水题,预处理字符串)

题干&#xff1a; You are given a string ss of length nn, which consists only of the first kk letters of the Latin alphabet. All letters in string ss are uppercase. A subsequence of string ss is a string that can be derived from ss by deleting some of its…

docker修改镜像的存储位置_云原生存储详解:容器存储与 K8s 存储卷(内含赠书福利)...

作者 | 阚俊宝 阿里巴巴技术专家参与文末留言互动&#xff0c;即有机会获得赠书福利&#xff01;导读&#xff1a;云原生存储详解系列文章将从云原生存储服务的概念、特点、需求、原理、使用及案例等方面&#xff0c;和大家一起探讨云原生存储技术新的机遇与挑战。本文为该系列…

vb简易计算机器程序,vb简易计算器源码

代码如下&#xff1a;/***Author:乌鸟heart*Version:1.0*/Dim IntX As Double 全局变量&#xff0c;用于存储计算的数值Dim IntOperation As Double 标记运算类型Dim isBegin As Boolean 标记是否已经给IntX赋值Public Sub Clear() 清空命令函数screen.Caption ""En…

【CodeForces - 1038B 】Non-Coprime Partition (构造,数组特征)

题干&#xff1a; Find out if it is possible to partition the first nn positive integers into two non-empty disjoint sets S1S1 and S2S2 such that: gcd(sum(S1),sum(S2))>1gcd(sum(S1),sum(S2))>1 Here sum(S)sum(S) denotes the sum of all elements presen…

计算机专业用锐龙笔记本,轻松应对工作挑战——ThinkPad T14 锐龙版,适合办公的笔记本电脑...

拥有一部适合办公的笔记本电脑&#xff0c;可以成为商务人士忙碌工作中强有力的支持。联想旗下的ThinkPad 系列笔记本电脑&#xff0c;一直秉持为高端商务人士服务的理念&#xff0c;以稳定、流畅、安全的使用体验得到广泛认可。其中的ThinkPad T14 锐龙版&#xff0c;更是有着…