Bzoj 2169 Side--the thought of the heavy

Source: Internet
Author: User

Title: https://www.lydsy.com/JudgeOnline/problem.php?id=2169

If you have been to a good weight before, you can be seen as the edge of this connection will only repeat with the last one.

It can be thought that from the last state to this state, the process of transfer for each state of the last time is the remaining position of all the possibility of the edge of the traverse just once! That is, I am currently connected to the edge, and the number of repetitions of the last Edge is C (n,2)-(I-2) (n points in the selection of 2 is a total number of empty slots, the last time I-2 was placed, this time with the last can be repeated position there is so many).

With respect to the same scheme because of the different order of the number of repeated counting, as long as the one side after each count divided by I can be, for each scheme, the side of this time may be placed on the side of the I bar any one, resulting in repetition. It is not possible to do so, and finally divide by the factorial of the number of edges that are filled, because their transfer is not tenable when it is transferred from a repeating state.

#include <iostream>#include<cstdio>#include<cstring>#include<algorithm>using namespacestd;Const intn=1005, mod=10007;intN,m,t,dp[n][n];BOOLDeg[n];intrdn () {intret=0;BOOLfx=1;CharCh=GetChar ();  while(ch>'9'|| ch<'0'){if(ch=='-') fx=0; ch=GetChar ();}  while(ch>='0'&&ch<='9') ret= (ret<<3) + (ret<<1) +ch-'0', ch=GetChar (); returnfx?ret:-ret;}intCalcintA) {return(A * (a)1) >>1)%MoD;}intpwintXintk) {  intret=1; while(k) {if(k&1) ret=ret*x%mod;x=x*x%mod;k>>=1;}returnret;}intMain () {n=rdn (); M=rdn (); t=RDN ();  for(intI=1, u,v;i<=m;i++) {u=rdn (); v=RDN (); Deg[u]=!deg[u]; deg[v]=!Deg[v]; }  intCnt=0;  for(intI=1; i<=n;i++) cnt+=Deg[i]; dp[0][cnt]=1;  for(intI=1; i<=t;i++)    {      intD=PW (i,mod-2);  for(intj=0; j<=n;j++) {Dp[i][j]=dp[i-1][j]*j%mod* (n-j)%MoD; DP[I][J]= (dp[i][j]+dp[i-1][j+2]*calc (j+2))%MoD; if(j>=2) Dp[i][j]= (dp[i][j]+dp[i-1][j-2]*calc (n-j+2))%MoD; if(i>1) dp[i][j]-=dp[i-2][j]* (Calc (n)-(i2))%MoD; if(dp[i][j]<0) dp[i][j]+=MoD; DP[I][J]=dp[i][j]*d%MoD; }} printf ("%d\n", dp[t][0]%MoD); return 0;}

Bzoj 2169 Side--the thought of the heavy

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.