AtCoder Beginner Contest 300G - P-smooth number解题报告

1 题目链接

传送门

2 题目大意

题目:P-光滑数的数量
题目大意:

在 1 1 1 到 n n n 中,有多少个数的所有质因数均不超过 p ( p ≤ 100 ) p\ (p\leq100) p (p≤100)。

3 解法分析

这道题看着很像搜索,于是你可以写出来一份 T L E TLE TLE 代码。

d f s ( x , y ) dfs(x,y) dfs(x,y) 表示在 ( x , p r m [ y ] ) (x, prm[y]) (x,prm[y]) 下单答案。
其中 p r m [ 37 ] prm[37] prm[37] 来存下 100 100 100 内的所有质数,因只有 25 25 25 个所以不如打表。

接下来考虑优化。

首先就是一个记忆化搜索,然后再剪枝。

十分显然的,从大质数向小质数搜可以有效避免无意义的搜索。

于是复杂度玄学起来,你也就 A C AC AC了。

4 解法总结

记搜+剪枝。

5 AC Code

#include <bits/stdc++.h>
#define int long long
#define N 1000000
using namespace std;int ans;
int n, m, inf;
int dp[26][2000007];int prm[37] = {2, 3, 5, 7,11, 13, 17, 19,23, 29, 31, 37,41, 43, 47,53, 59, 61, 67,71, 73, 79,83, 89, 97,1145141919810
};void dfs(int x, int y) {if (x <= N && dp[y][x]) {ans += dp[y][x];return ;}if (!y) {ans = ans + __lg(x) + 1;return ;}int cnt = ans;dfs(x, y - 1);if (x >= prm[y])dfs(x / prm[y], y);if (x <= N)dp[y][x] = ans - cnt;
}signed main() {scanf("%lld%lld", &n, &m);for (; prm[inf + 1] <= m; ++inf);dfs(n, inf);printf("%lld\n", ans);return 0;
}

AtCoder Beginner Contest 300G - P-smooth number解题报告相关推荐

  1. Atcoder Beginner Contest 260D - Draw Your Cards 解题报告

    Atcoder Beginner Contest 260D - Draw Your Cards 解题报告 1 题目链接 abc260_d 2 题目大意 题目 : 抽牌 题目大意 : 给定NNN个数字, ...

  2. Atcoder Grand Contest 012 B - Splatter Painting解题报告

    题目:http://agc012.contest.atcoder.jp/tasks/agc012_b 有一个n点m边的图,(不一定联通) 还有q个操作:每次将一个点v及其周围距离<=d的点涂成颜 ...

  3. Mynavi Programming Contest 2021(AtCoder Beginner Contest 201)题解

    文章目录 A - Tiny Arithmetic Sequence B - Do you know the second highest mountain? C - Secret Number D - ...

  4. AtCoder题解 —— AtCoder Beginner Contest 182 —— D - Wandering

    题目相关 题目链接 AtCoder Beginner Contest 182 D 题,https://atcoder.jp/contests/abc182/tasks/abc182_d. Proble ...

  5. Coprime AtCoder Beginner Contest 215

    Coprime AtCoder Beginner Contest 215 Time Limit: 2 sec / Memory Limit: 1024 MB Score : 400400 points ...

  6. AtCoder Beginner Contest 286——E - Souvenir

    AtCoder Beginner Contest 286 题目讲解 A题 B题 C题 D题 E题 蒟蒻来讲题,还望大家喜.若哪有问题,大家尽可提! Hello, 大家好哇!本初中生蒟蒻今天讲解一下At ...

  7. AtCoder题解 —— AtCoder Beginner Contest 187 —— B - Gentle Pairs —— 暴力

    题目相关 题目链接 AtCoder Beginner Contest 187 B 题,https://atcoder.jp/contests/abc187/tasks/abc187_b. Proble ...

  8. freee Programming Contest 2022(AtCoder Beginner Contest 264)A~D题详细讲解

    目录 博主赛情 网站链接 比赛简介 Contest Information Reason why freee needs AtCoder users freee's business content ...

  9. AtCoder Beginner Contest 282 A-E

    比赛名称:HHKB Programming Contest 2022 Winter(AtCoder Beginner Contest 282) 比赛链接:AtCoder Beginner Contes ...

最新文章

  1. SP-45ML光电二极管放大电路设计
  2. Investigating SQL Server 2008 Wait Events with XEVENTS
  3. Valgrind ---内存调试,内存泄漏检测以及性能分析的软件开发工具
  4. springboot初始化逻辑_SpringBoot——启动初始化数据
  5. python关键词提取_如何从Python格式字符串中提取关键字? - python
  6. 参数中带有“”符号问题
  7. 噪音测试软件+安卓,分贝噪音测试软件
  8. megacli通过盘符定位物理盘_Megaraid 磁盘定位
  9. 面向对象核心(继承)
  10. 如何按照规格型号表挑选合适的快速接头
  11. Java Excel 复制单元格 poi Excel 复制单元格 Java Excel 复制行 Java Excel 复制 sheet 页 poi excel copy
  12. 简单了解latex输出矩阵
  13. YB时代,数据保护的“难”与“易”
  14. pycharm汉化之后切换回英文
  15. 彻底弄懂LSH之simHash算法
  16. Java SE 复习
  17. 换发型算法_AI拍照换发型软件下载-AI拍照换发型下载V999.999-西西软件下载
  18. 策略路由指令:ip rule、ip route
  19. 安徽省支持科技创新政策通知,兑现项目奖补详情
  20. 单元测试框架:go convey

热门文章

  1. HTML5 实现页面滚动
  2. 安装驱动--20220204
  3. 通讯协议与即时通讯杂谈
  4. Python爬虫——解析插件JsonPath安装及使用
  5. 配置jenkins过程中Gitee无法添加证书令牌
  6. 问卷设计必看!这些技巧能让你的问卷更加高效!
  7. 组织行为学个人机制:员工学习与能力发展
  8. sprintf %m.ns %m.nf
  9. 网络编程简单入门,基础知识需先掌握
  10. oracle 完整性约束 unique和not null,oracle完整性约束