HDU 2521 反素数
来源:互联网 发布:java的helloworld代码 编辑:程序博客网 时间:2024/05/22 03:19
链接 : http://acm.hdu.edu.cn/showproblem.php?pid=2521
首先,了解一下反素数 :
对于任何正整数x,其约数的个数记做g(x).例如g(1)=1,g(6)=4.如果某个正整数x满足:对于任意i(0<i<x),都有g(i)<g(x),则称x为反素数【via:度娘】
也就是说,有一个数,它的约数的个数 比 比它小的数的约数个数 都要大,那么 这个数 就是 反素数(若理解有误请指正)
但是本题似乎跟反素数没什么关系 =.=
水题,上代码:
#include <iostream>using namespace std;int rec[5001]= {0,1};int factor(int n) //求每个数的约数个数{ int sum=0; for(int i=1; i<=n/2; i++) if(!(n%i)) sum+=2; return sum;}int main(){ for(int i=2; i<5001; i++) rec[i]=factor(i);//打表 int n,a,b; cin>>n; while(n-- && cin>>a>>b) { int ans=a; for(int i=a+1; i<=b; i++) //找区间内最大 ans=(rec[ans]>=rec[i]) ? ans : i; cout<<ans<<endl; } return 0;}
0 0
- 【素数】-HDU-2521-反素数
- HDU 2521 反素数
- HDU 2521 反素数
- hdu 2521 反素数
- hdu-2521-反素数
- HDU 2521 反素数
- hdu-2521-反素数
- hdu 2521 反素数
- HDU 2521 反素数
- hdu 2521 反素数
- HDU 2521 反素数
- hdu 2521 反素数
- HDU 2521 反素数
- hdu 2521 反素数(数论)
- hdu 2521(反素数)
- HDU 2521 反素数(区间反素数)
- hdu 2521 反素数 (水)
- HDU 2521 反素数【打表】
- 另一个ORM——MyBatis(二)
- 定时同步数据库表(mysql+linux+crontab)
- git学习教程
- Spring MVC防止数据重复提交
- webdriver for python模拟键盘操作
- HDU 2521 反素数
- Java Annotation原理分析(四) - 实现原理分析
- 基于.NET平台常用的框架整理
- Android Studio在build的时候出现transformClassesWithDexForDebug
- MVC简介(MVC是什么)
- Window下 Qt Creator 安装+Qt4.8.5+MinGW编译器+GDB调试器
- android studio异常Error:A problem was found with the configuration of task ':app:zipalignDebug'.
- session的两个小案例
- 一种更新yum源的简便方法