hdu2521 反素数(求约数个数)
来源:互联网 发布:select to SQL 编辑:程序博客网 时间:2024/06/08 14:41
http://acm.hdu.edu.cn/showproblem.php?pid=2521
题意:不解释。
思路:本来想看下反素数,范围太大的没什么思路,这题是求约数个数(其实是1~n-1范围内的约数个数,也不能叫约数了),只不过范围比较小,暴力解决。
好久没水,水一下应该没人打我吧。。
#include <stdio.h>#include <algorithm>#include <string.h>using namespace std;typedef long long ll;const int N = 5010;const int INF = 0x3f3f3f3f;int num[N];void table(){ memset(num, 0, sizeof(num)); for(int i = 1; i <= N; i++) { for(int j = 1; j <= (i/2+1); j++) { if(i%j == 0) num[i]++; } }}int main(){ // freopen("in.txt", "r", stdin); table(); int n, a, b, ans, maxx; scanf("%d", &n); while(n--) { maxx = -INF; scanf("%d%d", &a, &b); for(int i = a; i <= b; i++) maxx = max(maxx, num[i]); for(int i = a; i <= b; i++) if(num[i] == maxx) { ans = i; break; } printf("%d\n", ans); } return 0;}
0 0
- hdu2521 反素数(求约数个数)
- HDU2521(求因子个数)
- HDU2521:反素数
- HDU2521反素数
- HDU2521:反素数
- HDU2521 反素数【水题】
- HDU2521 反素数
- hdu2521:反素数
- HDU2521:反素数 .
- HDU2521 求因数个数
- HDU2521——反素数
- Vijos p1172 反质数(求约数个数)
- HDU2521 反素数【因子数量+打表】
- %ACDreamer数论大神带飞系列_反素数深度分析_求约数个数为n的最小整数
- 最复杂的数(约数个数定理+反素数性质)
- 求反素数个数模版总结
- SOJ-1748(求约数个数)
- 求约数个数问题
- RecycleView的UP和Down加载
- redis使用教程(安装和连接)
- Codeforces Round #401 (Div. 2) D. Cloud of Hashtags
- 高精度算法加法
- sys/time.h 是GCC的编译标准写法
- hdu2521 反素数(求约数个数)
- android studio 中 java.lang.NoClassDefFoundError:retrofit2.Retrofit$Builder错误解决
- warning: Error opening file (../../modules/highgui/src/cap_ffmpeg_impl.hpp:545)
- TensorFlow数据处理方法
- EasyRTMP内置IPCamera实现RTMP直播摄像机功能
- 索引并发(蟹行协议和B-Link树)
- 练习
- SSM框架——详细整合教程(Spring+SpringMVC+MyBatis)
- 算法提高 矩阵乘法