用x ^ (1 / n) 来求个数,容斥原理 , Num会向后移动, 迭代到不再变化,退出循环

#include<iostream>
#include<cstdio>
#include<cstring>
#include<vector>
#include<algorithm>
#include<cmath>
using namespace std;
typedef long long LL;
const int Primes[] = {-2,-3,-5,-7,-11,-13,-17,-19,-23,-29,-31,-37,-41,-43,-47,-53,-59,-61,-67,-71};
vector<int> R_number;
void GetR(LL R) {
R_number.clear();
for(int i = 0; abs(Primes[i])<= R; ++i) {
int tmp = Primes[i];
int Num = R_number.size();
for(int j = 0; j < Num; ++j) {
if(abs(R_number[j]*tmp) <= 63)
R_number.push_back(tmp * R_number[j]);
}
R_number.push_back(Primes[i]);
}
}
LL Cnt(LL N) {
//GetR(R);
if(N == 1) return 0;
LL cnt = N;
for(int i = 0; i < R_number.size(); ++i) {
LL tmp = LL (pow(N+0.5, 1.0/abs(R_number[i])) - 1);
if(R_number[i] < 0) cnt -= tmp;
else cnt += tmp;
}
return cnt - 1;
}
void Solve(LL N,LL R) {
GetR(R);
LL ans = N;
while(1) {
LL tmp = Cnt(ans);
if(tmp == N) break;
ans += N - tmp;
}
printf("%lld\n",ans);
}
int main() {
int t;
scanf("%d",&t);
while(t--) {
LL n,r;
scanf("%I64d %I64d",&n,&r);
Solve(n,r);
}
return 0;
}

HDU 5297的更多相关文章

  1. HDU 5297 Y sequence 容斥 迭代

    Y sequence 题目连接: http://acm.hdu.edu.cn/showproblem.php?pid=5297 Description Yellowstar likes integer ...

  2. HDU - 5297:Y sequence (迭代&容斥)

    Yellowstar likes integers so much that he listed all positive integers in ascending order,but he hat ...

  3. HDU 5297 Y sequence Y数列

    题意:给定正整数n和r.定义Y数列为从正整数序列中删除全部能表示成a^b(2 ≤ b ≤ r)的数后的数列,求Y数列的第n个数是多少. 比如n = 10. r = 3,则Y数列为2 3 5 6 7 1 ...

  4. [2015hdu多校联赛补题]hdu5297 Y sequence

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5297 题意:给你一个所有正整数的序列,然后去掉满足x^(2~r)的所有数(x为所有正整数,r>= ...

  5. 2015 Multi-University Training Contest 1 题解&&总结

    ---------- HDU 5288 OO’s Sequence 题意 给定一个数列(长度<$10^5$),求有多少区间[l,r],且区间内有多少数,满足区间内其它数不是他的约数. 数的范围$ ...

  6. HDOJ 2111. Saving HDU 贪心 结构体排序

    Saving HDU Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total ...

  7. 【HDU 3037】Saving Beans Lucas定理模板

    http://acm.hdu.edu.cn/showproblem.php?pid=3037 Lucas定理模板. 现在才写,noip滚粗前兆QAQ #include<cstdio> #i ...

  8. hdu 4859 海岸线 Bestcoder Round 1

    http://acm.hdu.edu.cn/showproblem.php?pid=4859 题目大意: 在一个矩形周围都是海,这个矩形中有陆地,深海和浅海.浅海是可以填成陆地的. 求最多有多少条方格 ...

  9. HDU 4569 Special equations(取模)

    Special equations Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u S ...

随机推荐

  1. ssh 跳板机部署

    1.首先创建存放日志的文件夹并开放读写权限       mkdir /var/log/jump/       chmod -R 777 /var/log/jump/   2.将原有ssh程序修改为另外 ...

  2. linux_网易云音乐安装

    使用命令安装一些基本包$ sudo apt install devscripts equivs git

  3. [Android] Android读取Asset下文件的最简单的方法总结(用于MediaPlayer中)

    方法一:getAssets().openFd //读取asset内容    private void openAssetMusic(String index) throws IOException { ...

  4. Scrapy基础02

    一.start_requests def start_requests(self): cls = self.__class__ if method_is_overridden(cls, Spider, ...

  5. MySQL Connector 编程

    MySQL Connector 是MySQL数据库客户端编程的接口, 它提供了通过网络访问数据库的接口, 这些功能在动态链接库(.dll, .so)或者静态对象库(.lib, .a)中实现. 使用时必 ...

  6. Nginx负载均衡session会话保持方法

    负载均衡时,为了保证同一用户session会被分配到同一台服务器上,可以使用以下方法: 1.使用cookie 将用户的session存入cookie里,当用户分配到不同的服务器时,先判断服务器是否存在 ...

  7. GCC编译器原理(一)05------GCC 工具:readelf、size、strings、strip和 windres

    1.3.18 readelf:elf 文件格式分析工具 这个工具和 objdump 命令提供的功能类似,但是它显示的信息更为具体,并且它不依赖 BFD 库( BFD 库是一个 GNU 项目,它的目标就 ...

  8. Redis Fun使用

    using Newtonsoft.Json; using StackExchange.Redis; using System; using System.Configuration; using Sy ...

  9. [SYSS-2018-033]: Fujitsu Wireless Keyboard Set LX901 - Keystroke Injection Vulnerability

    风险简介: [SYSS-2018-033]:富士通无线键盘组LX901 -击键注入漏洞 风险报告ID: sys - 2018 - 033 产品:无线键盘套件LX901 制造商:富士通 受影响版本:型号 ...

  10. 第26月第3天 java gradle

    1. 430 /Applications/Android\ Studio.app/Contents/gradle/gradle-2.8/bin/gradle -v 434 mkdir gradle01 ...