D - Matrix Multiplication

Time Limit: 2000/1000MS (Java/Others) Memory Limit: 128000/64000KB (Java/Others)

Problem Description

      Let us consider undirected graph G = {V; E} which has N vertices and M edges. Incidence matrix of this graph is N × M matrix A = {ai,j}, such that ai,j is 1 if i-th vertex is one of the ends of j -th edge and 0 in the other case. Your task is to find the sum of all elements of the matrix ATA.

Input

      The first line of the input file contains two integer numbers — N and M (2 ≤ N ≤ 10 000, 1 ≤ M ≤100 000). Then 2*M integer numbers follow, forming M pairs, each pair describes one edge of the graph. All edges are different and there are no loops (i.e. edge ends are distinct).

Output

      Output the only number — the sum requested.

Sample Input

4 4
1 2
1 3
2 3
2 4

Sample Output

18
 /*
* this code is made by 987690183
* Problem: 1213
* Verdict: Accepted
* Submission Date: 2014-10-14 13:40:27
* Time: 236MS
* Memory: 1716KB
*/
#include<iostream>
#include<stdio.h>
#include<cstring>
#include<cstdlib>
using namespace std; int num[];
long long get(int n,int m)/**Cn,m**/
{
long long sum = ;
for(int i=,j=n;i<=m;i++,j--)
sum=sum*j/i;
return sum;
}
int main()
{
int n,m,x,y;
int hxl= ;
while(scanf("%d%d",&n,&m)>)
{
memset(num,,sizeof(num));
for(int i=;i<=m;i++)
{
scanf("%d%d",&x,&y);
num[x]++;
num[y]++;
hxl = hxl+;
}
long long tom = hxl;
for(int i=;i<=;i++)
if(num[i]>=)
{
tom=tom+get(num[i],)*;
}
printf("%lld\n",tom);
}
return ;
}

acdeream Matrix Multiplication的更多相关文章

  1. 【数学】Matrix Multiplication

                                 Matrix Multiplication Time Limit: 2000MS   Memory Limit: 65536K Total S ...

  2. hdu 4920 Matrix multiplication bitset优化常数

    Matrix multiplication Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/ ...

  3. 矩阵乘法 --- hdu 4920 : Matrix multiplication

    Matrix multiplication Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/ ...

  4. hdu4920 Matrix multiplication 模3矩阵乘法

    hdu4920 Matrix multiplication Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 131072/131072 ...

  5. HDU 4920 Matrix multiplication 矩阵相乘。稀疏矩阵

    Matrix multiplication Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/ ...

  6. Matrix multiplication hdu4920

    Problem Description Given two matrices A and B of size n×n, find the product of them. bobo hates big ...

  7. HDU-4920 Matrix multiplication

    矩阵相乘,采用一行的去访问,比采用一列访问时间更短,根据数组是一行去储存的.神奇小代码. Matrix multiplication Time Limit: 4000/2000 MS (Java/Ot ...

  8. 数学(矩阵乘法,随机化算法):POJ 3318 Matrix Multiplication

    Matrix Multiplication Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 17783   Accepted: ...

  9. hdu 4920 Matrix multiplication(矩阵乘法)2014多培训学校5现场

    Matrix multiplication                                                                           Time ...

随机推荐

  1. HUD 5086 Revenge of Segment Tree(递推)

    http://acm.hdu.edu.cn/showproblem.php?pid=5086 题目大意: 给定一个序列,求这个序列的子序列的和,再求所有子序列总和,这些子序列是连续的.去题目给的第二组 ...

  2. zoj The 12th Zhejiang Provincial Collegiate Programming Contest Capture the Flag

    http://acm.zju.edu.cn/onlinejudge/showContestProblem.do?problemId=5503 The 12th Zhejiang Provincial ...

  3. javascript 一些常用的验证

    只能输入数字          onkeyup="this.value=this.value.replace(/[^\d]/g,'')" onafterpaste="th ...

  4. Listview和Gridview自定义分割线

    1,ListView和GridView中的每一个条目都有分割线,属性android:footerDividersEnabled表示是否显示分割线,默认是为true,即可见.可以自定义的设置分割线的颜色 ...

  5. paper 63 :函数比较:imfilter与fspecial

    功能:对任意类型数组或多维图像进行滤波. 用法:B = imfilter(A,H) B = imfilter(A,H,option1,option2,...) 或写作g = imfilter(f, w ...

  6. 【转】C#访问权限修饰符

    C#访问权限修饰符 C#中类及类型成员修饰符有以下四类:public,private,protected,internal. public        类及类型成员的修饰符 private 类型成员 ...

  7. 【secureCRT】如何在secureCRT上设置常用的快捷输出按钮栏

    转自:http://jingyan.baidu.com/article/5d6edee2f32de199eadeec25.html 方法/步骤   打开secureCRT软件,单击菜单栏上面的[查看] ...

  8. Linux之sed命令详解

    简介 sed 是一种在线编辑器,它一次处理一行内容.处理时,把当前处理的行存储在临时缓冲区中,称为“模式空间”(pattern space),接着用sed命令处理缓冲区中的内容,处理完成后,把缓冲区的 ...

  9. FormData对象

    FF4中增加了一个很有意思的对象,FormData.通常我们提交(使用submit button)时,会把form中的所有表格元素的name与value组成一个queryString,提交到后台.这用 ...

  10. linux系统修改CST时区

    ================================================= [root@tzyyserveryg ~]# date -R Fri, 28 Nov 2014 08 ...