CF817B Makes And The Product
思路:
模拟,数学。
实现:
#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的更多相关文章
- uva 11059 maximum product(水题)——yhx
aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAB1QAAAMcCAIAAABo0QCJAAAgAElEQVR4nOydW7msuhKF2wIasIAHJK
- [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 ...
- [LeetCode] Maximum Product Subarray 求最大子数组乘积
Find the contiguous subarray within an array (containing at least one number) which has the largest ...
- vector - vector product
the inner product Givens two vectors \(x,y\in \mathbb{R}^n\), the quantity \(x^\top y\), sometimes c ...
- 1 Maximum Product Subarray_Leetcode
Find the contiguous subarray within an array (containing at least one number) which has the largest ...
- Leetcode Maximum Product Subarray
Find the contiguous subarray within an array (containing at least one number) which has the largest ...
- 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 ...
- [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 ...
- sp_addlinkedserver '(null)' is an invalid product name
使用SSMS 2008客户端工具逆向生成了创建链接服务器的脚本时,在测试环境执行是报如下错误:'(null)' is an invalid product name. USE [master] GO ...
随机推荐
- 洛谷 P2033 Chessboard Dance
P2033 Chessboard Dance 题目描述 在棋盘上跳舞是件有意思的事情.现在给你一张国际象棋棋盘和棋盘上的一些子以及你的初始位置和方向.求按一定操作后,棋盘的状态. 操作有四种,描述如下 ...
- mysql转oracle注意事项
1.mysql中有自增长,oracle用新建sequence代替. 2.在实体类的id要指定相关的sequence @GeneratedValue(strategy=GenerationType.SE ...
- 打造Spring Cloud构建微服务架构的最全资料
访问: https://git.oschina.net/didispace/SpringCloud-Learning http://blog.didispace.com/categories/Spri ...
- WebForms UnobtrusiveValidationMode 须要“jquery”ScriptResourceMapping。
一.问题产生的背景: 在敲牛腩新闻公布系统的后台登录页面的时候,我们用到了RequiredFieldValidator控件(验证非空控件),该控件的作用是禁止输入规定的内容,RequiredField ...
- CI 知识 :Git介绍及常用操作
Git介绍 Git(读音为/gɪt/.)是一个开源的分布式版本控制系统,可以有效.高速的处理从很小到非常大的项目版本管理. Git 是 Linus Torvalds 为了帮助管理 Linux 内核开发 ...
- DirectX11 学习笔记7 - 支持自由移动的摄像机
如今将又一次制定一个camera摄像机.能够自由移动. 比方前进 后退,上游 下潜. 各个方向渲染之类的. 首先设置按键. 这个时候须要在 XWindow.h 里面 bool XWindow::fra ...
- MongDB应用
题外话 工作3年,了解的技术颇多,但都是一知半解,了解不是很透澈.用过的技术,就像猴子搬过的包谷,搬一个丢一个.几年风雨,真有点一缕清风过,片叶不沾身的味道. 为强化知识点,提升文档及学习能力,我把以 ...
- 读书笔记:Information Architecture for the World Wide Web, 3rd Edition 北极熊 第一部分 1-3
Introducing Information Architecture 信息架构简介 Chapter 1 Defining Information Architecture 信息架构的意义(我们盖房 ...
- linux之安装软件出现Could not open lock file /var/lib/dpkg/lock - open (13: Permission denied)解决总结
sudo rm -rf /var/lib/dpkg/lock sudo rm -rf /var/cache/apt/archives/lock
- HQL 查询数据 (获取页面输入的查询条件字段)
/* * 查询提取位置表所有数据 * */ public String ListEtlExtractPositionOfAll(){ // 接受数据库中传送的code int code = Integ ...