817B codeforces - Makes And The Product


817B codeforces - Makes And The Product







Solution in C++


#include <bits/stdc++.h>
using namespace std;

typedef long long int lli;
#define pii pair<int,int>

lli n,sol;

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    cin>>n;
    int nn[n];
    for(int i=0;i<n;i++)cin>>nn[i];
    sort(nn,nn+n);
    lli mx=count(nn,nn+n,nn[2]);
    if(nn[0]==nn[2])cout<<fixed<<setprecision(0)<<(mx)*(mx-1)*(mx-2)/6;
    else if(nn[1]==nn[2] )cout<<fixed<<setprecision(0)<<0.5*(mx)*(mx-1);
    else cout<<mx;
    return 0;
}

Share on Google Plus

About Mohamed Sobhi

My name is Mo.Sobhy ,I study at School excelling high school in Ain Shams ,Cairo
My hobbies is programming ,and web development ,playing chess and writing horror stories.
    Blogger Comment
    Facebook Comment

0 التعليقات:

إرسال تعليق