• prufer序列 图论?组合数学? BZOJ1430 小猴打架


    1430: 小猴打架

    Time Limit: 5 Sec  Memory Limit: 162 MB
    Submit: 655  Solved: 477
    [Submit][Status][Discuss]

    Description

    一开始森林里面有N只互不相识的小猴子,它们经常打架,但打架的双方都必须不是好朋友。每次打完架后,打架的双方以及它们的好朋友就会互相认识,成为好朋友。经过N-1次打架之后,整个森林的小猴都会成为好朋友。 现在的问题是,总共有多少种不同的打架过程。 比如当N=3时,就有{1-2,1-3}{1-2,2-3}{1-3,1-2}{1-3,2-3}{2-3,1-2}{2-3,1-3}六种不同的打架过程。

    Input

    一个整数N。

    Output

    一行,方案数mod 9999991。

    Sample Input

    4

    Sample Output

    96

    HINT

    50%的数据N<=10^3。
    100%的数据N<=10^6。

    prufer序列的裸题

     1 #include<iostream>
     2 #include<cstdio>
     3 #include<cstring>
     4 #include<algorithm>
     5 using namespace std;
     6 const int mod=9999991;
     7 int n;
     8 long long ans;
     9 int main(){
    10     ans=1;
    11     scanf("%d",&n);
    12     for(int i=1;i<=n-2;i++) ans=(ans*n)%mod;
    13     for(int i=1;i<=n-1;i++) ans=(ans*i)%mod;
    14     printf("%lld",ans);
    15     return 0;
    16 }
    17 
  • 相关阅读:
    要看的博客
    sleep(0)的妙用
    Spring Cloud:Eureka的多网卡IP选择问题
    SpringBoot整合swagger
    springboot整合redis(注解形式)
    RSA非对称加密
    java split(regex,limit) 使用记录
    windows git支持arc命令
    eclipse安装反编译插件
    使用@Validated分组遇到的坑
  • 原文地址:https://www.cnblogs.com/zwube/p/7134558.html
Copyright © 2020-2023  润新知