ACdream 1213 简单数学
来源:互联网 发布:纬创软件 福州 编辑:程序博客网 时间:2024/05/20 15:41
ACdream 1213
Matrix Multiplication
Time Limit: 2000/1000MS (Java/Others) Memory Limit: 128000/64000KB (Java/Others)
Submit Statistic Next Problem
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 41 21 32 32 4
Sample Output
18
Source
Andrew Stankevich Contest 1
Manager
mathlover
状态转移规律正好符合矩阵乘法
#include <iostream>#include <cstring>#include <cmath>#include <algorithm>#include <cstdio>using namespace std;int main(){ int n,m,x,y; cin>>n>>m; long long a[10005]={0}; long long ans=0; for(int i=0;i<m;i++){ cin>>x>>y; a[x]++;a[y]++; } for(int i=1;i<=n;i++){ ans+=a[i]*a[i]; } cout<<ans<<endl;}
0 0
- ACdream 1213 简单数学
- 1204 ACdream Integration of Polynomial(数学:简单求积分)
- acdream 1686(数学)
- acdream 1077(数学)
- acdream 群赛5 组合数学
- ACdream简单题目集
- ACdream 简单数据结构 专题
- ACdream 简单数论 专题
- Acdream 1065 同心树(数学)
- ACdream 1154 Lowbit Sum(数学:推理)
- 数学推导——ACdream 1067
- ACdream 1007 a + b (数学+快速幂)
- ACdream 1006 Mengzhu (数学推导)
- acdream 1124 BFS + 简单DP
- ACdream手速赛2简单题解
- acdream 1025 Transform 简单dp
- ACdream 1213 Matrix Multiplication
- ACdream 1213 Matrix Multiplication
- MES版本说明
- 【代码笔记】iOS-UITextField设置placeholder颜色
- PHP代码规范与质量检查工具PHPCS,PHPMD的安装与配置
- 什么是资本运营的核心?
- Swift 语言数据类型
- ACdream 1213 简单数学
- 屏幕旋转
- Android快速开发之设计通用的ListView,GridView的适配器
- 自动朗读(TTS)
- No mapping found for HTTP request with URI [/operation-platform/js/displaytag.js] in DispatcherServl
- 圆形背景TextView
- Visual Studio 2013 Professional Key
- R应用-多元线性回归
- 考取PMP的价值何在?