思路:

模拟,数学。

实现:

 #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. Redis集群方案收集

    说明: 如果不考虑客户端分片去实现集群,那么市面上基本可以说就三种方案最成熟,它们分别如下所示: 系统 贡献者 是否官方Redis实现 编程语言 Twemproxy Twitter 是 C Redis ...

  2. MongoDB小结10 - update【upsert】

    upsert是一个选项,它是update的第三个参数,并不是一个方法.它是一种特殊的更新,要是没有文档符合匹配,那么它就会根据条件和更新文档为基础,创建新的文档,如有匹配,则正常更新.咱们之前见到的所 ...

  3. SAS学习笔记 - 基本原理与概念

    1.赋值符号 由一个尖括号和一个符号组成,可以从左到右也可以从右到左,即“->”或者“<-”. 赋值号也可以使用等号“=”. 如果对象已经存在,那么原先的值会被覆盖.除了可以赋一个数值,还 ...

  4. mainboard

    MAINBOARD ★ CPU(type, speed, amount, cache, slot or socket, fan) ★ RAM(the most capacity, amount, fr ...

  5. SSD硬盘安装系统后要做的事

    1***cmd>fsutil behavior query DisableDeleteNotify 0如果返回值是0,则代表TRIM处于开启状态:反之如果返回值是1,则代表TRIM处于关闭状态2 ...

  6. 制作svg动画

    要实现一步一步画出来一个图片,css3做不到吧.除非一张张的图片定时显示.想不到别的招了.如今用的是一个插件,做了一个svg动画. 插件地址:http://lazylinepainter.info/ ...

  7. C#高级编程四十八天----列表

    C#中的List C#中deList怎么样?List<T>类是ArrayList类的泛型等效类,该类使用大小可按需动态增长的数组实现List<T>泛型接口. 泛型的优点:它为使 ...

  8. 1451 - Average 高速求平均值

    怎样高速求取一段区间的平均值 用前缀的思想来看 很easy 可是 本题题意要求的是 大于等于一段长度的区间的平均值的最大值 并且给出的数据范围非常大 O(n*L)的直白比較算法 用于解决此问题不合适 ...

  9. 何时、怎样开启 MySql 日志?

    假如你是一名 web 开发者.假设你想调试你的应用或提升其性能的话,那你须要去參考各种日志文件.日志是開始故障排除最好的选择.就著名的 MySql 数据库server而言,你须要參考下面日志文件: 错 ...

  10. 省市县三级联动js代码

    省市县三级联动菜单,JS全国省市县(区)联动代码,一般可以用于用户注册或分类信息二手交易网站,需要的朋友直接复制代码就可以用了,不过有朋友反馈说缺少某些城市,具体缺少哪个尚不知,请想用的朋友自己补全吧 ...