zoukankan      html  css  js  c++  java
  • Codeforces--630H--Benches(组合数)

    H - Benches

    Crawling in process... Crawling failed Time Limit:500MS     Memory Limit:65536KB     64bit IO Format:%I64d & %I64u

    Description

    The city park of IT City contains n east to west paths and n north to south paths. Each east to west path crosses each north to south path, so there are n2 intersections.

    The city funded purchase of five benches. To make it seems that there are many benches it was decided to place them on as many paths as possible. Obviously this requirement is satisfied by the following scheme: each bench is placed on a cross of paths and each path contains not more than one bench.

    Help the park administration count the number of ways to place the benches.

    Input

    The only line of the input contains one integer n (5 ≤ n ≤ 100) — the number of east to west paths and north to south paths.

    Output

    Output one integer — the number of ways to place the benches.

    Sample Input

    Input
    5
    
    Output
    120
    远看还以为是阶乘,--||然而n可以到一百,看了题才知道是组合数,东西向,南北向的路各n条,相互垂直的两条路一定会相交,形成了n*n个路口,现在5张长凳,
    把凳子放到路口,并且每条路只能出现一张凳子,那摩我们就要从南北向,东西向的路中各挑出5条,然后,,,,,,
    #include<cstdio>
    #include<cstring>
    #include<iostream>
    using namespace std;
    __int64 C(__int64 m,__int64 n)
    {
    	__int64 ans=1;
    	__int64 num=1;
    	while(n--)
    	{
    		ans*=(m-n);
    		ans/=num;
    		num++;
    	}
    	return ans;
    }
    int main()
    {
    	__int64 n;
    	while(cin>>n)
    	{
    		cout<<120*C(n,5)*C(n,5)<<endl;
    	}
    	return 0;
    }

  • 相关阅读:
    NES游戏历史
    NES资料
    Spring的自动装配
    springmvc框架如何将模型数据传递给视图 也就是Model>view参数的传递
    拆分Spring的配置文件
    Springmvc框架前台传值给controller @Requestparam @RequestMapping
    SpringMVC框架传入Map集合
    SpringMVC框架使用注解编写的处理请求和映射@Controller @RequestMapping
    SpringMVC初尝试
    MVC设计模式
  • 原文地址:https://www.cnblogs.com/playboy307/p/5273408.html
Copyright © 2011-2022 走看看