我们很容易找到:
a=7
b=8
c=a|b
Run Code Online (Sandbox Code Playgroud)
然后c出来是:15
现在我们可以找到a是否c给出了吗?
例如:
b=8
c=15
c=a|b
Run Code Online (Sandbox Code Playgroud)
找到?
而且如果x=2<<1给出,那么我们可以得到x=4。但是如果4=y<<1给出我们能得到y吗?
我正在用 Python 实现 GeeksForGeeks 中的贝尔曼·福特算法。我想使用一些库(如 pyplot 或 networkx 或类似的库)生成图表(图表形式,而不是字典类型 - 这很容易)。我希望图形 UI 包含节点、边和相应的成本。
from collections import defaultdict
#Class to represent a graph
class Graph:
def __init__(self,vertices):
self.V= vertices #No. of vertices
self.graph = [] # default dictionary to store graph
# function to add an edge to graph
def addEdge(self,u,v,w):
self.graph.append([u, v, w])
# utility function used to print the solution
def printArr(self, dist):
print("Vertex Distance from Source")
for i in range(self.V):
print("%d \t\t %d" % (i, dist[i]))
# The …Run Code Online (Sandbox Code Playgroud)