/*
枚举素数幂p
然后求k^p<=n 的 k的个数
因为 k^p1*p2==k^p2*p1,所以这两种情况是多算的,所以要进行容斥
减去两个质数幂相乘的,再加上三个质数幂相乘的
因为2*3*5*7>60,所以最多容斥两次就可以
枚举pi最为起点进行深搜,只搜比pi大的
*/
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int p[]={,,,,,,,,,,,,,,,,};
ll ans,n;
//素数下标pos,当前幂e,容斥标记(质数幂个数cnt)
void dfs(int pos,ll e,int cnt){
ll k=(ll)pow(n,1.0/e);
if(cnt%)ans+=k-;//k=1时不算
else ans-=k-;
if(cnt>)return;//不用往下搜了
for(int i=pos+;i<;i++)
dfs(i,e*p[i],cnt+);
}
int main(){
while(cin>>n){
ans=;
for(int i=;i<;i++)dfs(i,p[i],);
cout<<ans<<endl;
}
}

容斥原理——hdu2204dfs深搜的更多相关文章

  1. BZOJ_2393_Cirno的完美算数教室&&BZOJ_1853_[Scoi2010]幸运数字 _深搜+容斥原理

    BZOJ_2393_Cirno的完美算数教室&&BZOJ_1853_[Scoi2010]幸运数字 _深搜+容斥原理 题意: ~Cirno发现了一种baka数,这种数呢~只含有2和⑨两种 ...

  2. Bzoj 2393: Cirno的完美算数教室 容斥原理,深搜

    2393: Cirno的完美算数教室 Time Limit: 10 Sec  Memory Limit: 128 MBSubmit: 287  Solved: 175[Submit][Status][ ...

  3. Bzoj 1853: [Scoi2010]幸运数字 容斥原理,深搜

    1853: [Scoi2010]幸运数字 Time Limit: 2 Sec  Memory Limit: 64 MBSubmit: 1774  Solved: 644[Submit][Status] ...

  4. HDU--杭电--1195--Open the Lock--深搜--都用双向广搜,弱爆了,看题了没?语文没过关吧?暴力深搜难道我会害羞?

    这个题我看了,都是推荐的神马双向广搜,难道这个深搜你们都木有发现?还是特意留个机会给我装逼? Open the Lock Time Limit: 2000/1000 MS (Java/Others)  ...

  5. 利用深搜和宽搜两种算法解决TreeView控件加载文件的问题。

    利用TreeView控件加载文件,必须遍历处所有的文件和文件夹. 深搜算法用到了递归. using System; using System.Collections.Generic; using Sy ...

  6. 2016弱校联盟十一专场10.3---Similarity of Subtrees(深搜+hash、映射)

    题目链接 https://acm.bnu.edu.cn/v3/problem_show.php?pid=52310 problem description Define the depth of a ...

  7. 2016弱校联盟十一专场10.2---Around the World(深搜+组合数、逆元)

    题目链接 https://acm.bnu.edu.cn/v3/problem_show.php?pid=52305 problem  description In ICPCCamp, there ar ...

  8. 2015暑假多校联合---Cake(深搜)

    题目链接:HDU 5355 http://acm.split.hdu.edu.cn/showproblem.php?pid=5355 Problem Description There are m s ...

  9. 深搜+回溯 POJ 2676 Sudoku

    POJ 2676 Sudoku Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 17627   Accepted: 8538 ...

随机推荐

  1. Metasploit 如何使用Exploits(漏洞)

    在Metasploit中选择一个漏洞利用程序将'exploit'和'check'命令添加到msfconsole. msf > use exploit/windows/smb/ms09_050_s ...

  2. 54Mbps、150Mbps、433Mbps 你知道这三个Wi-Fi速率怎么算的吗?

           802.11g能够提供54Mbps的最大速率, 802.11n和802.11ac单流分别能够提供150Mbps和433Mbps的最大速率,这些数字是怎么算的呢?(看红字,更容易理解哟) ...

  3. java-day16

    FileWriter 文件字符输出流 extends Writer 构造方法 FileWriter(String filename) FileWriter(File file) flush()方法:刷 ...

  4. 【2018ACM/ICPC网络赛】焦作赛区

    A Magic Mirror 题目链接:https://nanti.jisuanke.com/t/31710 题意:输入字符串,如果是“Jessy”就输出“Good Guy!",否则输出“D ...

  5. centos yum install 找不到软件包

    yum install epel-release 然后再试试yum install 其他安装包

  6. 2019-7-3-Roslyn-在项目文件使用条件判断

    title author date CreateTime categories Roslyn 在项目文件使用条件判断 lindexi 2019-7-3 17:7:32 +0800 2018-8-3 2 ...

  7. 安装keepalived 出现configure: error: Popt libraries is required

    keepalived执行./configure --prefix=/usr/local/keepalived时报错:configure: error: Popt libraries is requir ...

  8. 7.spark运行模式

    sparkbin目录下     ./pyspark --help       http://spark.apache.org/docs/latest/submitting-applications.h ...

  9. dos中文显示乱码怎么办?

    其实只需要一条命令 chcp 65001 执行该操作后,代码页就被变成UTF-8了 也可是GBK,  命令式:  chcp  936 2.修改窗口属性,改变字体 在命令行标题栏上点击右键,选择&quo ...

  10. iOS ARC下命名规则

    当我在ARC模式下写以下代码的时候,编译器报错 Semantic Issue: Property's synthesized getter follows Cocoa naming conventio ...