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. 树形DP+RMQ+单调队列(Bob’s Race HDU4123)

    题意:有n个房子,这些房子被n-1条道路连接,有一些运动员从一个房子为起点尽可能跑最远的距离且不能通过一条道路超过两次,这些运行员不能选择同样的起点,这些运动员跑的最远距离和最近距离的差值不能超过Q, ...

  2. fzuoj Problem 2177 ytaaa

    http://acm.fzu.edu.cn/problem.php?pid=2177 Problem 2177 ytaaa Accept: 113    Submit: 265Time Limit: ...

  3. Java基础(3):求任意数字的长度的三种方法

    题目:统计任意一个数字的长度 方法一:先把数字转换为字符换,再直接用现成的函数统计长度即可 方法二:用API public class Test { final static int[] sizeTa ...

  4. paper 1:图像特征提取

    特征提取是计算机视觉和图像处理中的一个概念.它指的是使用计算机提取图像信息,决定每个图像的点是否属于一个图像特征.特征提取的结果是把图像上的点分为不同的子集,这些子集往往属于孤立的点.连续的曲线或者连 ...

  5. 动态时间规整(DTW) 转载

    Dynamic Time Warping(DTW)诞生有一定的历史了(日本学者Itakura提出),它出现的目的也比较单纯,是一种衡量两个长度不同的时间序列的相似度的方法.应用也比较广,主要是在模板匹 ...

  6. qlserver、Mysql、Oracle三种数据库的优缺点总结

    这篇文章主要介绍了sqlserver.Mysql.Oracle三种数据库的优缺点总结,需要的朋友可以参考下   一.sqlserver优点:易用性.适合分布式组织的可伸缩性.用于决策支持的数据仓库功能 ...

  7. 把Nodepad++添加进右键菜单

    1.运行注册表编辑器:开始->运行->regedit 2.找到HKEY_CLASSES_ROOT/*/shell 3.右击shell,选择 新建->项 4.项的名字为Edit wit ...

  8. Auto push git tag

    CALL "C:\Program Files\TortoiseGit\bin\pageant.exe" "d:\CKey.ppk" set GIT_SSH=C: ...

  9. 分数的加减法——C语言初学者代码中的常见错误与瑕疵(12)

    前文链接:分数的加减法——C语言初学者代码中的常见错误与瑕疵(11) 重构 题目的修正 我抛弃了原题中“其中a, b, c, d是一个0-9的整数”这样的前提条件,因为这种限制毫无必要.只假设a, b ...

  10. SessionHelper

    MXS&Vincene  ─╄OvЁ  &0000009 ─╄OvЁ  MXS&Vincene MXS&Vincene  ─╄OvЁ:今天很残酷,明天更残酷,后天很美好 ...