http://acm.hznu.edu.cn/OJ/problem.php?cid=1263&pid=7

http://acm.hznu.edu.cn/OJ/problem.php?id=2586

题意:问对每个x问xy > yx的y个数。

题解:

对式子取ln,得到ylnx > xlny,则y/lny > x/lnx。

不考虑精度误差的话,按这个值排序即可。

然而确实是会有误差导致可能的答案错误,如果你缘分地过了,那么恭喜你。

怎么避免精度误差呢?——考虑x/lnx的单调性

求导后大家会发现导函数的极值点是e,所以如果所有数字都大于e的话,直接排序就好了。这时有两个例外:1和2,提前拿出来特判算答案贡献即可。

一些corner case:ln1=0         24=42

题解:

特殊考虑1 2 3 4

其他按从小到大,先按最大为0,依次递减赋值答案,相同值答案相同;

再考虑3,需要加上2的个数

再考虑2,需要减去3和4的个数

所有数的答案除1以外,需要加上1的个数

1一定为零。

/*
*@Author:   STZG
*@Language: C++
*/
#include <bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<cstdlib>
#include<cstring>
#include<cstdio>
#include<string>
#include<vector>
#include<bitset>
#include<queue>
#include<deque>
#include<stack>
#include<cmath>
#include<list>
#include<map>
#include<set>
//#define DEBUG
#define RI register int
using namespace std;
typedef long long ll;
//typedef __int128 lll;
const int N=100000+10;
const int M=100000+10;
const int MOD=1e9+7;
const double PI = acos(-1.0);
const double EXP = 1E-8;
const int INF = 0x3f3f3f3f;
int t,n,m,k,q;
int ans,cnt,flag,temp,sum;
struct node{int a,id,ans;bool operator <(const node&S)const{return a<S.a;}
}e[N];
bool cmp(node a,node b){return a.id<b.id;
}
int a[N];
int c[N];
int d[N];
int main()
{
#ifdef DEBUGfreopen("input.in", "r", stdin);//freopen("output.out", "w", stdout);
#endif//ios::sync_with_stdio(false);//cin.tie(0);//cout.tie(0);//scanf("%d",&t);//while(t--){scanf("%d",&n);int b[5]={0,0,0,0,0};for(int i=1;i<=n;i++){scanf("%d",&e[i].a);if(e[i].a<=4){b[e[i].a]++;}e[i].id=i;}sort(e+1,e+n+1);e[n+1].a=e[n].a;c[n+1]=b[1];for(int i=n;i>=1;i--){if(e[i+1].a>e[i].a){c[i]=n-i+b[1];}else{c[i]=c[i+1];}d[i]=c[i];if(e[i].a==1){d[i]=0;}else if(e[i].a==2){d[i]-=b[3]+b[4];}else if(e[i].a==3){d[i]+=b[2];}e[i].ans=d[i];}sort(e+1,e+n+1,cmp);for(int i=1;i<=n;i++){printf("%d%c",e[i].ans," \n"[i==n]);}//}#ifdef DEBUGprintf("Time cost : %lf s\n",(double)clock()/CLOCKS_PER_SEC);
#endif//cout << "Hello world!" << endl;return 0;
}

Little Sub and Counting相关推荐

  1. DFS:深入优先搜索 POJ-2386 Lake Counting

    深度优先搜索是从最开始的状态出发,遍历所有可以到达的状态. 因此可以对所有的状态进行操作,或列举出所有的状态. Lake Counting POJ - 2386 Due to recent rains ...

  2. Boring counting HDU - 3518 (后缀数组)

    Boring counting \[ Time Limit: 1000 ms \quad Memory Limit: 32768 kB \] 题意 给出一个字符串,求出其中出现两次及以上的子串个数,要 ...

  3. pat1004. Counting Leaves (30)

    1004. Counting Leaves (30) 时间限制 400 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue A fam ...

  4. CF990G GCD Counting(树上莫比乌斯反演,分层图,并查集)

    整理的算法模板合集: ACM模板 点我看算法全家桶系列!!! 实际上是一个全新的精炼模板整合计划 Problem 给定一棵点带权无根树,对于每个 k∈[1,2×105]k\in[1,2\times10 ...

  5. 2019 ACM - ICPC 上海网络赛 E. Counting Sequences II (指数型生成函数)

    繁凡出品的全新系列:解题报告系列 -- 超高质量算法题单,配套我写的超高质量题解和代码,题目难度不一定按照题号排序,我会在每道题后面加上题目难度指数(1∼51 \sim 51∼5),以模板题难度 11 ...

  6. 人群密度估计--Structured Inhomogeneous Density Map Learning for Crowd Counting

    Structured Inhomogeneous Density Map Learning for Crowd Counting https://arxiv.org/abs/1801.06642 针对 ...

  7. 人群密度估计--Leveraging Unlabeled Data for Crowd Counting by Learning to Rank

    Leveraging Unlabeled Data for Crowd Counting by Learning to Rank CVPR2018 https://github.com/xialeil ...

  8. 人群密度估计--Crowd Counting Via Scale-adaptive Convolutional Nerual Network

    Crowd Counting Via Scale-adaptive Convolutional Nerual Network https://arxiv.org/abs/1711.04433v2 Co ...

  9. 人群密度估计--Learning a perspective-embedded deconvolution network for crowd counting

    Learning a perspective-embedded deconvolution network for crowd counting 没有找到代码 本文在人群密度估计这个问题上的创新点: ...

  10. CNN数玉米穗--TasselNet: Counting maize tassels in the wild via local counts regression network

    TasselNet: Counting maize tassels in the wild via local counts regression network https://link.sprin ...

最新文章

  1. 电商运营-跨境开网店全图解
  2. 使用opencv自带的融合函数
  3. android内核编译 me525,摩托罗拉DEFY(ME525)刷Android 2.3.4变砖后的解决方法
  4. 第十二单元文件的归档/压缩/传输
  5. c mysql批量添加数据类型_mybatis学习之路----mysql批量新增数据
  6. 麻瓜编程python爬虫微专业_麻瓜编程 - 主页
  7. 进度条的另外一种用法
  8. 事业单位计算机初级考试科目一模拟试题,广东教师资格考试之科目一模拟题
  9. 4t硬盘实际容量是多少_SMR硬盘到底能用不?点进来看看避免踩雷
  10. Java分割字符split与StringTokenizer
  11. redis 内存溢出_Redis 为何这么快?聊聊它的数据结构~
  12. 漫画:什么是图的最小生成树?
  13. clark变换第三行系数的由来
  14. 子列和列_最大子列和
  15. 华为P7开启USB调试方法
  16. 更新极路由器1S,HC5661A刷breed再刷老毛子华硕教程
  17. ubuntu conda、pip 设置代理
  18. linux rm 提示权限不足
  19. Matlab傅里叶级数展开(附结果图)
  20. 我们都需要时间,成为更好的人(转载)

热门文章

  1. 卸载注册表_系统小技巧:软件卸载不了?这里办法多
  2. python基本随机生成函数_Python学习笔记(三):随机生成函数方法
  3. python将大于输出列表_程序检查列表中的所有值是否都大于Python中的给定值
  4. 换主板会影响oracle数据库吗,nas瞎折腾 篇一:J3455更换h310+8700t es折腾作业
  5. php 二维数组值相加,php二维数组指定某元素后面的值是和前面的值相加起来的...
  6. Centos7搭建Kubernetes集群
  7. 主题模型LDA的实现
  8. 深圳内推 | 华为诺亚方舟实验室招聘机器学习/深度学习算法实习生
  9. 直播 | 复旦大学许燚:少量标注样本场景下基于数据编程的半监督分类
  10. 今日arXiv精选:Transformer专题论文推荐