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 ...
 
随机推荐
- ORACLE 按表字段值的不同统计数量
			
select p.id comperitorId,p.compcorp competitorName, sum(case when c.kindname = 'ATM' then c.num else ...
 - MySQL调优 —— Using temporary
			
DBA发来一个线上慢查询问题. SQL例如以下(为突出重点省略部分内容): select distinct article0_.id, 等字段 from article_table article ...
 - nyoj--102--次方求模(快速幂)
			
次方求模 时间限制:1000 ms | 内存限制:65535 KB 难度:3 描述 求a的b次方对c取余的值 输入 第一行输入一个整数n表示测试数据的组数(n<100) 每组测试只有一行,其 ...
 - Eclipse 连接hsqldb数据库
			
初学Java,在接触数据库根本无从下手,不知如何将程序和数据库连接起来,今天做一个记录. 数据库是:hsqldb_1_8_0_5 附链接百度云盘 链接:https://pan.baidu.com/s/ ...
 - BZOJ 1537 cdq分治
			
思路: 我只是想写一下cdq-- 二维偏序 一维排序 一维cdq分治 (我忘了归并排序怎么写了,,,) 写了个sort- 复杂度是O(nlog^2n) //By SiriusRen #include ...
 - BZOJ 1507 splay
			
写完维修数列 这不是水题嘛233333 //By SiriusRen #include <cstdio> #include <cstring> #include <alg ...
 - html基础知识整理
			
html 标题 <h1>这是一级标题</h1> <h2>这是二级标题</h2> <h3>这是三级标题</h3> html注释: ...
 - 第5章分布式系统模式 在 .NET 中使用 DataSet 实现 Data Transfer Object
			
要在 .NET Framework 中实现分布式应用程序.客户端应用程序需要显示一个窗体,该窗体要求对 ASP.NET Web Service 进行多个调用以满足单个用户请求.基于性能方面的考虑,我们 ...
 - Css float 盒子模型 position
			
属性: float 浮动 浮动的内容用div包起来,给div设置宽高 clear 清除浮动. box-sizing 标准模式下的盒模型 content-box:(默认属性) padding和borde ...
 - jQueryDOM操作模块
			
DOM操作模块 1.复习选择器模块(选择器模块结束) 目的:学而时习之 复习和总结选择器模块 2.DOM的基本操作方法 目标:回顾DOM操作的基本方法 3.1 DOM操作 -创建节点 练习 1:创建1 ...