HDU 2521
了解反素数的定义:
反素数是指[1,n]内,比n小的数的约数个数都比n的约数个数要少。注意n其实是最后一个。而在区间内,[a,b]是明显无法满足条件的。
注意了最大才5000.所以,不妨使用枚举。
#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;
const int M=5005;
int d[M]; void Initial(){
for(int i=1;i<M;i++)
d[i]=1;
for(int i=2;i<M;i++){
for(int j=i;j<M;j+=i)
d[j]++;
}
} int main(){
Initial();
// cout<<"YES"<<endl;
int a,b,t;
scanf("%d",&t);
while(t--){
scanf("%d%d",&a,&b);
int ma=-1,ans;
for(int i=a;i<=b;i++){
if(d[i]>ma){
ma=d[i];
ans=i;
}
}
printf("%d\n",ans);
}
return 0;
}
一道迷惑人的好题。
HDU 2521的更多相关文章
- HDOJ(HDU) 2521 反素数(因子个数~)
Problem Description 反素数就是满足对于任意i(0< i < x),都有g(i) < g(x),(g(x)是x的因子个数),则x为一个反素数.现在给你一个整数区间[ ...
- HDU 2521 反素数 模拟题
解题报告:水题,直接附上代码,只是觉得这题的作者是不是吃饱了饭撑的,反素数的概念跟这题一点关系都没有. #include<cstdio> int judge1(int k) { ; ;i& ...
- HDU 2521 反素数(数论,比较)
#include<iostream> #include<cstring> #include<cmath> #include<cstdio> using ...
- hdu 2521 反素数(打表)
反素数 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submiss ...
- 求n的因子个数与其因子数之和
方法一:朴素算法:O(n). #include<bits/stdc++.h> using namespace std; int get_num(int n){ ; ;i<=n;++i ...
- HDU——PKU题目分类
HDU 模拟题, 枚举1002 1004 1013 1015 1017 1020 1022 1029 1031 1033 1034 1035 1036 1037 1039 1042 1047 1048 ...
- [转] HDU 题目分类
转载来自:http://www.cppblog.com/acronix/archive/2010/09/24/127536.aspx 分类一: 基础题:1000.1001.1004.1005.1008 ...
- HDU ACM 题目分类
模拟题, 枚举1002 1004 1013 1015 1017 1020 1022 1029 1031 1033 1034 1035 1036 1037 1039 1042 1047 1048 104 ...
- HDU 5643 King's Game 打表
King's Game 题目连接: http://acm.hdu.edu.cn/showproblem.php?pid=5643 Description In order to remember hi ...
随机推荐
- CentOS6.8 安装 mysql 5.6
安装前的准备: 1.确认是否安装过mysql: yum list installed | grep mysql 2.删除系统自带的mysql及其依赖命令: yum -y remove mysql-li ...
- Task.ConfigureAwait
public ConfiguredTaskAwaitable ConfigureAwait( bool continueOnCapturedContext ) Configures an awaite ...
- 搭建自己的websocket server_1
用Node.js实现一个WebSocket的Server. https://github.com/sitegui/nodejs-websocket#event-errorerr nodejs-we ...
- 第19章 Redis的一些常用技术
19.1 Redis的基础事务 图19-1 Redis命令执行事务的过程 19-1:在Spring中使用Redis ...
- 2-1 Restful中HTTP协议介绍
Restful是一种基于资源的软件架构风格,所以从定义上来说是跟HTTP无关的.但是本课程提到的Restful API是基于HTTP协议的一种实现.所有相关知识都是基于现有的HTTP协议而来,并没有对 ...
- 关于H5优化的一些问题
required修改默认提示 : <form action="abc.php"> <input type="text" required o ...
- SwiftUI 官方教程(一)
完整中文教程及代码请查看 https://github.com/WillieWangWei/SwiftUI-Tutorials 创建和组合 View 此部分将指引你构建一个发现和分享您喜爱地方的 ...
- BZOJ 1196 二分+Kruskal
思路: 二分答案 判一下能不能加 //By SirisuRen #include <cstdio> #include <cstring> #include <algori ...
- Linux od与hexdump命令
od命令:以指定格式输出文件内容常用格式:od -Ax -tx1 filename直接格式:od filename 等价 od -o filename语法:od [-abcdfsiloxv] [-An ...
- 移动web开发常见的问题
1.屏幕旋转的事件和样式 事件 window.orientation,取值:正负90表示横屏模式.0和180表现为竖屏模式: window.onorientationchange = function ...