freepeople性欧美熟妇, 色戒完整版无删减158分钟hd, 无码精品国产vα在线观看DVD, 丰满少妇伦精品无码专区在线观看,艾栗栗与纹身男宾馆3p50分钟,国产AV片在线观看,黑人与美女高潮,18岁女RAPPERDISSSUBS,国产手机在机看影片

正文內(nèi)容

華東師范大學(xué)計(jì)算機(jī)機(jī)試真題-文庫吧

2025-03-12 01:42 本頁面


【正文】 such a plan of hub connection, that the cost is minimal. partychen will provide you all necessary information about possible hub connections. You are to help partychen to find the way to connect hubs so that all above conditions are satisfied. Input The first line of the input contains two integer numbers: N the number of hubs in the network (2 = N = 1000) and M the number of possible hub connections (1 = M = 15000). All hubs are numbered from 1 to N. The following M lines contain information about possible connections the numbers of two hubs, which can be connected and the cable cost required to connect them. cost is a positive integer number that does not exceed 106. There will always be at least one way to connect all hubs. Output Output the minimize cost of your hub connection plan. Sample Input 4 61 2 11 3 11 4 22 3 13 4 12 4 1 Sample Output 3includeincludealgorithmusing namespace std。struct Edge{int a,b。int cost。}E[15010]。int Tree[1010]。int findRoot(int x){if(Tree[x]==1)return x。else{int tmp=findRoot(Tree[x])。Tree[x]=tmp。return tmp。}}bool Cmp(Edge a,Edge b){return 。}int main(){int n。int m。int i。while(scanf(%d,amp。n)!=EOF){scanf(%d,amp。m)。for(i=1。i=m。i++)scanf(%d%d%d,amp。E[i].a,amp。E[i].b,amp。E[i].cost)。sort(E+1,E+1+m,Cmp)。//排序for(i=1。i=n。i++)Tree[i]=1。int ans=0。for(i=1。i=m。i++){int a=findRoot(E[i].a)。int b=findRoot(E[i].b)。if(a!=b){Tree[a]=b。ans+=E[i].cost。}}printf(%d\n,ans)。}return 0。}*編譯原理Principles of Compiler Description After learnt the Principles of Compiler,partychen thought that he can solve a simple expression he give you strings of less than 100 characters which strictly adhere to the following grammar (given in EBNF): A:= 39。(39。 B39。)39。|39。x39。. B:=AC. C:={39。+39。A}.Can you solve them too? Input The first line of input gives the number of cases, N(1 ≤ N ≤ 100). N test cases follow.The next N lines will each contain a string as described above. Output For each test case,if the expression is adapt to the EBNF above output “Good”,else output “Bad”. Sample Input 3(x)(x+(x+x))()(x) Sample Output GoodGoodBad include cstdioinclude cstringinclude cstdlibinclude vectorinclude cmathinclude iostreaminclude algorithminclude functionalinclude stringinclude mapinclude cctype using namespace std。char ex[110]。int index。bool A()。bool B()。bool C()。bool A(){ if(ex[index]==39。x39。) { index++。 while(ex[index]==39。 39。) index++。 return true。 } if(ex[index]==39。(39。) { index++。 while(ex[index]==39。 39。) index++。 if(B()amp。amp。ex[index]==39。)39。) { index++。 while(ex[index]==39。 39。) index++。 return true。 } } return false。}bool B(){ return A()amp。amp。C()。}bool C(){ while(ex[index]==39。+39。) { index++。 while(ex[index]==39。 39。) index++。 //return A()。 if (!A()) return false。 } return true。}int main(){ int N。 scanf(%d,amp。N)。 getchar()。 while(N) { gets(ex)。 index=0。 printf(%s\n,A()amp。amp。ex[index]==39。\039。?Good:Bad)。 } return 0。}*分開連接Separate Connections Description Partychen are analyzing a munications network with at most 18 nodes. Character in a matrix i,j (i,j both 0based,as matrix[i][j]) denotes whether nodes i and j can municate (39。Y39。 for yes, 39。N39。 for no). Assuming a node cannot municate with two nodes at once, return the maximum number of nodes that can municate simultaneously. If node i is municating with node j then node j is municating with node i. Input The first line of input gives the number of cases, N(1 ≤ N ≤ 100). N test cases follow.In each test case,the first line is the number of nodes M(1 ≤ M ≤ 18),then there are a grid by M*M describled the matrix. Output For each test case , output the maximum number of nodes that can municate simultaneously Sample Input 25NYYYYYNNNNYNNNNYNNNNYNNNN5NYYYYYNNNNYNNNYYNNNYYNYYN Sample Output 24HintThe first test case: All munications must occur with node 0. Since node 0 can only municate with 1 node at a time, the output value is 2.The second test case: In this setup, we can let node 0 municate with node 1, and node 3 municate with node 4. include cstdioinclude cstringinclude cstdlibinclude vectorinclude cmathinclude iostreaminclude algorithminclude functionalinclude stringinclude mapinclude queueusing namespace std。define MAXN 250define MAXE MAXN*MAXN*2define SET(a,b) memset(a,b,sizeof(a))dequeint Q。bool g[MAXN][MAXN],inque[MAXN],inblossom[MAXN]。int match[MAXN],pre[MAXN],base[MAXN]。int findancestor(int u,int v){ bool inpath[MAXN]= {false}。 while(1) { u=base[u]。 inpath[u]=true。 if(match[u]==1)break。 u=pre[match[u]]。 } while(1) { v=base[v]。 if(inpath[v])return v。 v=pre[match[v]]。 }}void reset(int u,int anc){ while(u!=anc) { int v=match[u]。 inblossom[base[u]]=1。 inblossom[base[v]]=1。 v=pre[v]。 if(base[v]!=anc)pre[v]=match[u]。 u=v。 }}void contract(int u,int v,int n){ int anc=findancestor(u,v)。 SET(inblossom,0)。 reset(u,anc)。 reset(v,anc)。 if(base[u]!=anc)pre[u]=v。 if(base[v]!=anc)pre[v]=u。 for(int i=1。 i=n。 i++) if(inblossom[base[i]]) { base[i]=anc。 if(!inque[i]) { (i)。 inque[i]=1。 } }}bool dfs(int S,int n){ for(int
點(diǎn)擊復(fù)制文檔內(nèi)容
教學(xué)課件相關(guān)推薦
文庫吧 www.dybbs8.com
備案圖鄂ICP備17016276號(hào)-1