CodeForces
来源:互联网 发布:linux中怎么创建文件 编辑:程序博客网 时间:2024/06/05 15:37
题目大意:
给你一串数,问你有个三元组(a,b,c)满足: a * b * c 小于等于任意三个元素的乘积。
代码:
#include<bits/stdc++.h>using namespace std;int a[100060];long long int C(int x,int y){ long long int ans=0; if(x==2) { ans=(long long int)y*(long long int)(y-1); ans/=2; } else { ans=(long long int)y*(long long int)(y-1)*(long long int)(y-2); ans/=6; } return ans;}int main(){ int n; scanf("%d",&n); for(int i=0;i<n;i++) { scanf("%d",&a[i]); } sort(a,a+n); int num[3]={0}; int flag=0; int t=a[0]; num[0]++; for(int i=1;i<n;i++) { if(flag>=3)break; if(a[i]>t) { t=a[i]; flag++; } num[flag]++; } //cout<<num[0]<<num[1]<<num[2]<<endl; if(num[0]>=3) { printf("%lld",C(3,num[0])); } else { if(num[0]==2) { printf("%d",num[1]); } else { if(num[1]>=2)printf("%lld",C(2,num[1])); else printf("%d",num[2]); } }}
阅读全文
0 0
- codeforces~~~
- Codeforces
- codeforces
- Codeforces
- codeforces
- codeforces
- Codeforces
- Codeforces
- CodeForces
- CodeForces
- CodeForces
- CodeForces
- CodeForces
- Codeforces
- Codeforces
- Codeforces
- Codeforces
- Codeforces
- 关于Autosar中DCM(14229UDS)模块的理解
- centos发行版视频解码问题的解决
- 单向链表-移动
- CURL发送HTTP请求获得Json数据串保存在本地(linux 下 C++ 编程)
- MySQL 修改字段类型或长度
- CodeForces
- 点击item将图片用Dialog以Viewpager形式展示出来,并放大缩小
- JAVA小结
- VMware安装Linux-Ubuntu系统(二)-安装vmware tools
- HDU6147(2017百度之星程序设计大赛
- Adroidstudio中创建数据库
- OGG:Oracle to MySQL异构复制环境搭建
- Find the nondecreasing subsequences(数状数组+离散化+dp)
- 聊聊session的安全性