1 条题解

  • 0
    @ 2018-01-18 21:24:51

    #include <iostream>
    #include <cmath>
    using namespace std;
    long long a[10000001];
    long long n;
    void quicksort (long long left,long long right)
    {
    long long i,j,temp;
    if (left>right)
    return;
    i=left;
    j=right;
    temp=a[left];
    while (i!=j)
    {
    while ((a[j]>=temp)&&(i<j))
    {
    j--;
    }
    while ((a[i]<=temp)&&(i<j))
    {
    i++;
    }
    if(i<j)
    swap(a[i],a[j]);
    }

    a[left]=a[i];
    a[i]=temp;
    quicksort (left,i-1);
    quicksort (i+1,right);
    }
    int main ()
    {
    long long c,sum=1;
    cin>>n;
    for (long long x=1;x<=n;x++)
    cin>>a[x];
    quicksort (1,n);
    for (long long x=1;x<=n;x++)
    {
    if (a[x]==a[x+1])
    {
    sum++;
    }
    if (a[x]!=a[x+1])
    {
    cout<<a[x]<<" "<<sum<<endl;
    sum=1;
    }
    }
    return 0;
    }

  • 1

信息

难度
6
分类
(无)
标签
递交数
57
已通过
16
通过率
28%
上传者