zoukankan      html  css  js  c++  java
  • bzoj2916: [Poi1997]Monochromatic Triangles 思路

    bzoj2916: [Poi1997]Monochromatic Triangles

    链接

    bzoj

    思路

    总方案(C_{n}^{3}-异色三角形)
    异色三角形有个特点。
    会出现两个点有两条不同色的边。
    然后统计就行了。

    代码

    #include <bits/stdc++.h>
    #define ll long long
    using namespace std;
    const int _=5e3+7;
    int n,m,a[_];
    int main() {
    	scanf("%d%d",&n,&m);
    	for(int i=1,u,v;i<=m;++i) {
    		scanf("%d%d",&u,&v);
    		a[u]++,a[v]++;
    	}
    	ll tot=0,ans=1LL*n*(n-1)*(n-2)/6;
    	for(int i=1;i<=n;++i) tot+=(n-a[i]-1)*a[i];
    	ans-=tot/2;
    	cout<<ans<<"
    ";
    	return 0;
    }
    
  • 相关阅读:
    TS 3.1
    TS 3.1
    TS 3.1
    TS 3.1
    TS 3.1
    TS 3.1
    测试面试总结02
    测试出的缺陷(bug)
    测试用例的内容
    微信发红包测试要点
  • 原文地址:https://www.cnblogs.com/dsrdsr/p/11405972.html
Copyright © 2011-2022 走看看