B. Makes And The Product
time limit per test

2 seconds

memory limit per test

256 megabytes

input

standard input

output

standard output

After returning from the army Makes received a gift — an array a consisting of n positive integer numbers. He hadn't been solving problems for a long time, so he became interested to answer a particular question: how many triples of indices (i,  j,  k)(i < j < k), such that ai·aj·ak is minimum possible, are there in the array? Help him with it!

Input

The first line of input contains a positive integer number n (3 ≤ n ≤ 105) — the number of elements in array a. The second line contains n positive integer numbers ai (1 ≤ ai ≤ 109) — the elements of a given array.

Output

Print one number — the quantity of triples (i,  j,  k) such that i,  j and k are pairwise distinct and ai·aj·ak is minimum possible.

Examples
input
4
1 1 1 1
output
4
input
5
1 3 2 3 4
output
2
input
6
1 3 3 1 3 2
output
1
Note

In the first example Makes always chooses three ones out of four, and the number of ways to choose them is 4.

In the second example a triple of numbers (1, 2, 3) is chosen (numbers, not indices). Since there are two ways to choose an element 3, then the answer is 2.

In the third example a triple of numbers (1, 1, 2) is chosen, and there's only one way to choose indices.

题意:

给一串数字,在其中选三个数字,使得这三个数字的乘积最小,问有多少个这样的组合

思路:

直接排序乘积最小那么这三个数字必定是最小的三个,又因为数字可能相同,会产成不同结果的情况一共有三种:

1.三个数字都相同 。

2.第一个和第二个不同,第二个与第三个相同。

3.第二个和第三个不同。

实现代码:

#include<iostream>
#include<algorithm>
#include<map>
using namespace std;
#define ll long long
map<ll,ll>mp;
int main()
{
ll m,i,a[];
cin>>m;
for(i=;i<m;i++){
cin>>a[i];
mp[a[i]]++;}
sort(a,a+m);
ll sum = ;
if(a[]==a[]&&a[]==a[]){
ll num = mp[a[]];
sum = (num*(num-)*(num-))/;
}
if(a[]!=a[]){
ll num = mp[a[]];
sum = num;
}
if(a[]!=a[]&&a[]==a[]){
ll num = mp[a[]];
// num = 99999;
sum = (num*(num-))/;
} cout<<sum<<endl;
}

Educational Codeforces Round 23 B. Makes And The Product的更多相关文章

  1. Educational Codeforces Round 23 E. Choosing The Commander trie数

    E. Choosing The Commander time limit per test 2 seconds memory limit per test 256 megabytes input st ...

  2. Educational Codeforces Round 23.C

    C. Really Big Numbers time limit per test 1 second memory limit per test 256 megabytes input standar ...

  3. Educational Codeforces Round 23 F. MEX Queries 离散化+线段树

    F. MEX Queries time limit per test 2 seconds memory limit per test 256 megabytes input standard inpu ...

  4. Educational Codeforces Round 23 D. Imbalanced Array 单调栈

    D. Imbalanced Array time limit per test 2 seconds memory limit per test 256 megabytes input standard ...

  5. Educational Codeforces Round 23 C. Really Big Numbers 暴力

    C. Really Big Numbers time limit per test 1 second memory limit per test 256 megabytes input standar ...

  6. Educational Codeforces Round 23 补题小结

    昨晚听说有教做人场,去补了下玩. 大概我的水平能做个5/6的样子? (不会二进制Trie啊,我真菜) A. 傻逼题.大概可以看成向量加法,判断下就好了. #include<iostream> ...

  7. Educational Codeforces Round 23

    A题 分析:注意两个点之间的倍数差,若为偶数则为YES,否则为NO #include "iostream" #include "cstdio" #include ...

  8. Educational Codeforces Round 23 A-F 补题

    A Treasure Hunt 注意负数和0的特殊处理.. 水题.. 然而又被Hack了 吗的智障 #include<bits/stdc++.h> using namespace std; ...

  9. Educational Codeforces Round 40千名记

    人生第二场codeforces.然而遇上了Education场这种东西 Educational Codeforces Round 40 下午先在家里睡了波觉,起来离开场还有10分钟. 但是突然想起来还 ...

随机推荐

  1. 2-微信小程序开发(开发界面说明,按钮点击切换显示内容)

    说一个功能,大家在用微信实现控制设备的时候,是不是都在为绑定设备发愁. 我看了很多厂家的微信控制,大部分都只是可以用微信给设备配网,但是没有做用微信绑定的. 一般做绑定都是用设备的MAC地址. 这里我 ...

  2. 源码分享篇:使用Python进行QQ批量登录

    直接上源码 1 #coding=utf-8 2 __author__ = 'Eagle' 3 import os 4 import time 5 import win32gui 6 import wi ...

  3. LED恒流驱动IC汇总

    LED恒流驱动IC汇总 2017年09月22日 11:29:01 阅读数:569 这几天在找LED恒流驱动芯片,无意间在LED网论坛上发现这个帖子,分享给大家! LED恒流IC芯片大盘点        ...

  4. MySql 数据库移植记录

    在使用长文本时,SqlServer 在以下情况下工作正常 [Property("CContent", ColumnType = "StringClob", Le ...

  5. jdk8+Mybatis3.5.0+Mysql读取LongBlob失败

    问题:在mysql中存储base64,因为太长,基本就是几百K,所以用longBlob 描述:在mysql中,LongBlob.blob算是二进制流文件了,所以用普通的数据格式是不行的,这里用Type ...

  6. 11.10 (下午)开课二个月零六天(ajax验证用户名,ajax调数据库)

    用ajax验证用户名是否可用 testuid.php <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN&quo ...

  7. synchronized和Lock的异同

    JAVA语言使用两种机制来实现堆某种共享资源的同步,synchronized和Lock.其中,synchronized使用Object对象本身的notify.wait.notifyAll调度机制,而l ...

  8. oracle如何导出和导入数据库/表

    oracle如何导出和导入数据库/表 oracle如何将项目中的表导出后在导入自己的数据库中,这是一个完整的操作,对于数据库备份或在本地查看数据验证数据进场用到,一般情况下我都用dos黑窗口进行操作, ...

  9. @Pointcut的用法

    在Spring 2.0中,Pointcut的定义包括两个部分:Pointcut表示式(expression)和Pointcut签名(signature).让我们先看看execution表示式的格式: ...

  10. Centos6.9下RocketMQ3.4.6高可用集群部署记录(双主双从+Nameserver+Console)

    之前的文章已对RocketMQ做了详细介绍,这里就不再赘述了,下面是本人在测试和生产环境下RocketMQ3.4.6高可用集群的部署手册,在此分享下: 1) 基础环境 ip地址 主机名 角色 192. ...