Codeforces Round #142 (Div. 1), problem: (C) Triangles
来源:互联网 发布:mac ae导出快捷键 编辑:程序博客网 时间:2024/05/16 06:53
题意:把一个完全图割裂成两部分,问现在还剩下的三角形个数。
走法:直接可以确定出被毁坏的三角形个数。被毁坏的情况是,原本三角形的某个点有两条线段指向它,并且由此构成一个三角形,现在却少了一条边,三角形被破坏,统计所有这样的情况
#include<cstdio>#include<iostream>#define LL long longusing namespace std;const int LMT=1000004;LL A[LMT];int main(void){ LL n,m,dama=0; int a,b; cin>>n>>m; while(m--) { scanf("%d%d",&a,&b); A[a]++;A[b]++; } for(int i=1;i<=n;i++) dama+=A[i]*(n-1-A[i]); cout<<n*(n-1)*(n-2)/6-dama/2<<endl; return 0;}
- Codeforces Round #142 (Div. 1), problem: (C) Triangles
- Codeforces Round #142 (Div. 1) C. Triangles
- Codeforces Round #142 (Div. 1) C. Triangles
- Codeforces Round #309 (Div. 1) C. Love Triangles 二分图
- Codeforces Round #142 (Div. 1) C. Triangles 数学,完全图,统计贡献 2017/1/25
- 解题报告:Codeforces Round #142 (Div. 1) C. Triangles (思维好题)
- Codeforces Round #142 (Div. 2) E. Triangles
- CodeForces Round #142(229C) - Triangles
- Codeforces Round #309 (Div. 1) C. Love Triangles(二分图)
- Codeforces Round #210 (Div. 1) problem C Levko and Strings
- Codeforces Round #137 (Div. 2), problem: (C)
- Codeforces Round #173 (Div. 2) Problem C
- Codeforces Round #Pi (Div. 2) Problem C
- Codeforces Round #363 (Div. 2), problem: (C)
- Codeforces Round #296 (Div. 1) E. Triangles 3000
- Codeforces Round #112 (Div. 2) C Another Problem on Strings
- Codeforces Round #198 (Div. 2) C. Tourist Problem - 找规律
- Codeforces Round #198 (Div. 2) C. Tourist Problem
- 程序员学习能力提升三要素
- Understanding Hadoop Clusters and the Network
- 【小题目】母牛产小牛问题
- 我所理解的HBase
- 以太网交换机芯片
- Codeforces Round #142 (Div. 1), problem: (C) Triangles
- Js获取当前日期时间及其它操作
- UVa 101 - The Blocks Problem
- vc 绘图
- 过了20岁,等不了你了
- java的事件驱动
- DLL的静态信息
- c++ 内存管理 完整版
- java匿名类监听器