ZOJ Problem Set - 3708 Density of Power Network


1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

#include <stdio.h>

#include <string.h>

int main(int argc, char *argv[])

{

    int T,i,j,lineSum;

    int N,M;    

    int x[505],y[505];

    int lineL [505][505] ;

     

    scanf("%d",&T);

    for(i = 0 ; i < T ;i++){                   

        lineSum = 0;           

        scanf("%d %d",&N,&M);

         

         

        memset (lineL,0,sizeof(lineL));

        memset (lineL,0,sizeof(x));

        memset (lineL,0,sizeof(y));

         

        for(j = 0 ; j < M ;j++){

            scanf("%d",&x[j]);     

        }

        for(j = 0 ; j < M ;j++){

            scanf("%d",&y[j]);

        }

        for(j = 0 ; j < M ;j++){

            if(lineL[x[j]][y[j]] == 0 && lineL[y[j]][x[j]] == 0){

                 

                lineSum ++;

                lineL[x[j]][y[j]]=lineL[y[j]][x[j]]=1; 

                 

            }

        }      

        printf("%.3f\n",lineSum/(N*1.0));

    }

     

    return 0;

}

  

时间: 2024-10-24 23:45:16

ZOJ Problem Set - 3708 Density of Power Network的相关文章

poj 1459 Power Network

click here ~~ ***Power Network*** Description A power network consists of nodes (power stations, consumers and dispatchers) connected by power transport lines. A node u may be supplied with an amount s(u) >= 0 of power, may produce an amount 0 <= p(

ZOJ Problem Set - 3713

题意:给定一个字符串,用字符串ASC2码16进制数输出 ,并在前面输出字符串长度的16进制,输出长度的规则是 先输出长度的二进制数的后七位的十六进制(如果左边还有1 则这在后七位前面加上个1再输出  然后二进制数右移动七位,直到左边没有1)   注:所有16数都必须为两位! 解题思路:对长度进行输出处理 解题代码: #include<stdio.h> #include<string.h> #include<stdlib.h> #include<time.h>

ZOJ Problem Set - 3706

#include <cstdio> #include <cstdlib> #include <cstring> #include <set> #include <iostream> #include <algorithm> using namespace std; set<int> ST; int find(int a, int b, int c) { ST.clear(); ST.insert(0); ST.insert

ZOJ Problem Set - 2397 Tian Ji -- The Horse Racing

#include<iostream> #include<cmath> #include<algorithm> #define REP(i,n) for(int i=0;i<(n);i++) using namespace std; int a[2000],b[2000],n; int main(){ while (cin>>n,n){ REP(i,n)cin>>a[i]; REP(i,n)cin>>b[i]; sort(a,a+

ZOJ Problem Set - 1730 Crazy Tea Party

#include<cstdio> int main(){ int T,n; scanf("%d",&T); while(T--){ scanf("%d",&n); printf("%d\n",n/2*(n/2-1)/2+(n-n/2)*(n-n/2-1)/2); } return 0; }

ZOJ Problem Set - 3758 素数

Singles' Day Time Limit: 2 Seconds Memory Limit: 65536 KB Singles' Day(or One's Day), an unofficial holiday in China, is a pop culture entertaining holiday on November 11 for young Chinese to celebrate their bachelor life. With the meaning of single

UVa 1267 Network:DFS&amp;amp;贪心

1267 - Network Time limit: 3.000 seconds http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=456&page=show_problem&problem=3708 Consider a tree network with n nodes where the internal nodes correspond to servers a

poj 3164 Command Network:最小树形图模板题

链接: http://poj.org/problem?id=3164 题目: Command Network Time Limit: 1000MS     Memory Limit: 131072K Total Submissions: 8922     Accepted: 2609 Description After a long lasting war on words, a war on arms finally breaks out between littleken's and Knu

Management Network

人们提到SDN,逻辑往往是这样的:控制和转发平面分离,由于有了SDN控制器的中心控制,我们可以做各种天花乱坠的事情.那么SDN控制器和交换机之间是通过怎样的网络进行通信的呢?一个与之相关的更大的问题是:作为一个完整的SDN解决方案,我们应该如何规划Management Network呢?这个问题也是所有客户最关心的前三个问题之一.博主想通过这篇文章抛砖引玉,聊聊在设计数据中心Management Network时要考虑的问题.   在没有SDN和orchestration系统之前,数据中心里往往