G - Greatest IME

 IME Starters Try-outs 2018

G - Greatest IME 

Statements

IME students are going to their first military field training. They will be placed in certain areas, individually, but a student in a certain area may be able to see other areas, so, in order to avoid distractions, no student should be able to see any other.

Earlier, for field reconnaissance, soldiers were placed in all areas. During that, two IMPORTANT things were noticed:

  • The sum of the number soldiers that each soldier could see is 2×n−2, where n is the number of soldiers;
  • If an officer says to any soldier to raise his hand and to all others to only raise theirs if they see another soldier with their hand already raised, eventually all soldiers will have raised their hand.

IME instructors are asking you to help them to find out how many students at most can be placed at the same time. To do so, they will give you which areas can be seen from each area.

Input

The first line contains two integers, nn and mm (1≤n≤105, 0≤m≤min(105,n×(n−1)/2)) — the number of areas and the number of relations.

The next mm lines contains the relations between the areas. Each line has two integers, aiai and ajaj (1≤ai,aj≤n), meaning that students in the areas aiai and ajaj can see each other.

Output

Output the number of students that can do the activity at the same time without seeing others.

Example

Input

5 4
1 2
1 3
2 4
2 5

Output

3

做法:快速幂+逆元+阶乘

高中数学题…………

  • 每队3人。队内6种情况。
  • n个队。6的次方。
  • m个座位,每队看成一个,相当于m-3*n+n=m-2n个座位坐n个人。
  • 排列数A(m-2n,n)
  • 乘起来………

这期中有一个逆元的概念。

推荐一个,看完就会了……

https://blog.csdn.net/baidu_35643793/article/details/75268911

代码如下……有点丑(一开始出了点问题,各种检测修改,最后懒得整理了)……

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll mod=1000000007;
ll n,c,ni;
ll quick(ll a,ll b)
{
    ll ans=1;
    while(b)
    {
        if(b&1) ans=(a*ans)%mod;
        a=(a*a)%mod,b>>=1;

    }
    return ans;
}

ll inv (ll a)
{
    return quick(a,mod-2);
}
ll cal(ll a)
{
    ll ans=1;
    for(int i=1; i<=a; i++)
    {

        ans*=i;
        ans=ans%mod;
    }
    return ans;

}



int main()
{
    ll sum=1;
    cin>>n>>c;
    ll k1,k2,k3,k4;
    k1=quick(6,n);
    k2=cal(n);
    k3=cal(c-2*n);
    k4=(cal(c-3*n)*cal(n))%mod;
    ni=inv(k4);
    sum=(k3*ni)%mod;
    sum=(sum*k1%mod*k2)%mod;
    cout<<sum<<endl;
    return 0;
}

猜你喜欢

转载自blog.csdn.net/xuanhuangwendao/article/details/81194603