思路:

模拟,数学。

实现:

 #include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std; const int MAXN = ; typedef long long ll; int a[MAXN], last[], num[], n; ll cnm(int n, int m)
{
ll s = ;
int k = ;
if(m > n / )
m = n - m;
for(int i = n - m + ; i <= n; i++)
{
s *= (ll)i;
while(k <= m && s % k == )
{
s /= (ll)k;
k++;
}
}
return s;
} int main()
{
scanf("%d", &n);
for (int i = ; i < n; i++)
scanf("%d", &a[i]);
sort(a, a + n);
int cnt = ;
last[] = ;
int i = ;
while (i < n)
{
if (a[i] != a[last[cnt]])
{
num[cnt] = i - last[cnt];
last[++cnt] = i;
}
if (cnt == ) break;
i++;
}
while (a[i] == a[last[cnt]] && i < n) i++;
num[cnt] = i - last[cnt];
if (num[] >= ) cout << cnm(num[], ) << endl;
else if (num[] == ) cout << num[] << endl;
else if (cnt == || num[] >= ) cout << cnm(num[], ) << endl;
else cout << num[] << endl;
return ;
}

CF817B Makes And The Product的更多相关文章

  1. uva 11059 maximum product(水题)——yhx

    aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAB1QAAAMcCAIAAABo0QCJAAAgAElEQVR4nOydW7msuhKF2wIasIAHJK

  2. [LeetCode] Product of Array Except Self 除本身之外的数组之积

    Given an array of n integers where n > 1, nums, return an array output such that output[i] is equ ...

  3. [LeetCode] Maximum Product Subarray 求最大子数组乘积

    Find the contiguous subarray within an array (containing at least one number) which has the largest ...

  4. vector - vector product

    the inner product Givens two vectors \(x,y\in \mathbb{R}^n\), the quantity \(x^\top y\), sometimes c ...

  5. 1 Maximum Product Subarray_Leetcode

    Find the contiguous subarray within an array (containing at least one number) which has the largest ...

  6. Leetcode Maximum Product Subarray

    Find the contiguous subarray within an array (containing at least one number) which has the largest ...

  7. Where product development should start

    We all need to know our customers in order to create products they’ll actually buy. This is why the  ...

  8. [LintCode] Product of Array Except Self 除本身之外的数组之积

    Given an integers array A. Define B[i] = A[0] * ... * A[i-1] * A[i+1] * ... * A[n-1], calculate B WI ...

  9. sp_addlinkedserver '(null)' is an invalid product name

    使用SSMS 2008客户端工具逆向生成了创建链接服务器的脚本时,在测试环境执行是报如下错误:'(null)' is an invalid product name. USE [master] GO ...

随机推荐

  1. node使用npm一句命令停止某个端口号 xl_close_port

    一命令停止某一个端口号,再也不怕端口号被占用了.. 1.插件背景 开启项目的时候,跑不起来了? 很多时候的原因就是,依赖版本,依赖的包未安装,再就是端口号被占用 例如: 这时候,我们做法就是: 1.到 ...

  2. guava cache学习

    Guava Cache与ConcurrentMap很相似,但也不完全一样.最基本的区别是ConcurrentMap会一直保存所有添加的元素,直到显式地移除.相对地,Guava Cache为了限制内存占 ...

  3. [52ABP系列] - 002、模板项目配合代码生成器开发

    前言 本篇的主要内容是 52ABP SPA模板如何配合52ABP代码生成器开发项目 如果不了解 52ABP 项目请先看我的第一篇文章 [52ABP系列] - 001.SPA免费项目模版搭建教程 话不多 ...

  4. 学习javascript 非常好的博客

    这个大牛写的非常好!!推荐一下 http://www.cnblogs.com/xiaohuochai/tag/javascript%E6%80%BB%E7%BB%93/default.html?pag ...

  5. http://www.cnblogs.com/sprinkle/

    http://www.cnblogs.com/sprinkle/ http://www.cnblogs.com/sprinkle/

  6. 戴尔PowerEdge服务器RAID控制卡的配置

    示例演示环境:PowerEdge R620 + H710p Raid控制卡  + 9 x 300G 10k SAS 硬盘 H310.H710.H810的配置方法与H710P大致相同,在此不再累述. 特 ...

  7. C#程序如何把窗体文件从从一个项目中复制到另一个项目

    一个窗体有三个文件,全部拷贝到新的项目中   在新的项目中点击显示所有文件,然后右击导入的文件,点击包括在项目中,会自动修改颜色(此时还没有被识别为窗体)   重启这个项目,三个文件已经被识别出来了 ...

  8. 10.11无法打开Xcode6.4的解决方法

    前言 mac升级到10.11版本号并安装Xcode7.0Beta之后,Dock中的Xcode6.3图标上出现一个禁止符号,打开提示到App store更新最新版本号,更新到6.4之后问题依然,还是提示 ...

  9. COCOS学习笔记--即时动作ActionInstant

    Cocos引擎中的动作类的关系图例如以下: 能够看出,Action是继承自Ref类的,之前我的博客中也有讲过,Ref类是cocos2dx全部类的基类.动作类(Action)是全部动作的基类.它通过cr ...

  10. grep结合awk简单用法

    一.grep简介: grep (缩写来自Globally search a Regular Expression and Print)是一种强大的文本搜索工具,它能使用正则表达式搜索文本,并把匹配的行 ...