zoukankan      html  css  js  c++  java
  • H.Little Sub and Counting

    Description

    Little Sub likes Math. Now he has a simple counting problem for you.
    Given an positive integer sequence A, for each Ai, Please calculate how many elements Aj in the sequence satisfied Ai^Aj > Aj^Ai.

    Input

    The first line contains one positive integer n(1 ≤ n ≤ 100000).
    The following line contains n positive integers Ai(1 ≤ Ai ≤ 2^31 − 1).

    Output

    Please output n integer in one line and separate them by a single space. The ith integer indicates the answer concerning Ai.

    Author
    CHEN, Jingbang

    题解:xy>yx -->取ln --> ylnx>xlny-->x/lnx<y/lny,以此为依据排序统计个数即可.
    #include <iostream>
    #include <cstdio>
    #include <algorithm>
    #include <cmath>
    const int N=1e5+5;
    using namespace std;
    typedef long long ll;
    double a[N];
    double b[N];
    int main()
    {
        int n;
        scanf("%d",&n);
        for(int i=1;i<=n;i++) scanf("%lf",&a[i]),a[i]=1.0*a[i]/log(a[i]),b[i]=a[i];
        sort(b+1,b+1+n);
        for(int i=1;i<=n-1;i++){
            printf("%d ",n-(upper_bound(b+1,b+1+n,a[i])-b)+1);
        }
        printf("%d ",n-(upper_bound(b+1,b+1+n,a[n])-b)+1);
        //cout << "Hello world!" << endl;
        return 0;
    }
    
    
  • 相关阅读:
    Java代理(jdk静态代理、动态代理和cglib动态代理)
    Hive安装
    Spark 集群安装
    Flume 远程写HDFS
    Spark Idea Maven 开发环境搭建
    oracle 通不过网络的原因
    oracle一些基本问题
    linux-redhat配置yum源
    liunx虚拟机网络连接
    redhat安装jdk、tomcat、mysql
  • 原文地址:https://www.cnblogs.com/-yjun/p/10549916.html
Copyright © 2011-2022 走看看