2015 Multi-University Training Contest 1 y sequence
Y sequence
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)
Total Submission(s): 667 Accepted Submission(s): 147
2,3,5,6,7,10......
Given positive integers n and r,you should output Y(n)(the n-th number of Y sequence.It is obvious that Y(1)=2 whatever r is).
Then T cases follow, each contains two positive integer n and r described above.
n<=2*10^18,2<=r<=62,T<=30000.
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int p[] = {, , , , , , , , , , , , , , , , , , };
vector<int>d;
LL n,r;
void init() {
d.clear();
for(int i = ; p[i] <= r; ++i) {
for(int j = d.size()-; j >= ; --j)
if(abs(d[j]*p[i]) <= ) d.push_back(-d[j]*p[i]);
d.push_back(p[i]);
}
}
LL calc(LL x){
if(x == ) return ;
LL ret = x;
for(int i = d.size()-; i >= ; --i){
LL tmp = pow(x+0.5,1.0/abs(d[i])) - ;
if(d[i] < ) ret += tmp;
else ret -= tmp;
}
return ret-;
}
LL solve(){
init();
LL ret = n;
while(true){
LL tmp = calc(ret);
if(tmp == n) break;
ret += n - tmp;
}
return ret;
}
int main() {
ios::sync_with_stdio(false);
int kase;
cin>>kase;
while(kase--){
cin>>n>>r;
cout<<solve()<<endl;
}
return ;
}
2015 Multi-University Training Contest 1 y sequence的更多相关文章
- 2018 Multi-University Training Contest 1 Balanced Sequence(贪心)
题意: t组测试数据,每组数据有 n 个只由 '(' 和 ')' 构成的括号串. 要求把这 n 个串排序然后组成一个大的括号串,使得能够匹配的括号数最多. 如()()答案能够匹配的括号数是 4,(() ...
- HDU - 6304(2018 Multi-University Training Contest 1) Chiaki Sequence Revisited(数学+思维)
http://acm.hdu.edu.cn/showproblem.php?pid=6304 题意 给出一个数列的定义,a[1]=a[2]=1,a[n]=a[n-a[n-1]]+a[n-1-a[n-2 ...
- 2018 Multi-University Training Contest 1-1002 -Balanced Sequence(括号匹配+贪心)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=6299 题目: 题意:t组数据,每组数据给你一个n表示给你n个括号串,这n个括号串之间进行组合,求能够匹 ...
- 2015 Multi-University Training Contest 1 - 10010 Y sequence
Y sequence Problem's Link: http://acm.hdu.edu.cn/showproblem.php?pid=5297 Mean: 有连续数列A={1,2,3,4,5,6, ...
- 2015 Multi-University Training Contest 2 hdu 5306 Gorgeous Sequence
Gorgeous Sequence Time Limit: 6000/3000 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Othe ...
- hdu 5288 OO’s Sequence(2015 Multi-University Training Contest 1)
OO's Sequence Time Limit: 4000/2000 MS (Jav ...
- 2015 Multi-University Training Contest 6 hdu 5357 Easy Sequence
Easy Sequence Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Others)T ...
- 2015 Multi-University Training Contest 1 OO’s Sequence
OO’s Sequence Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Others)T ...
- 2015 Multi-University Training Contest 8 hdu 5390 tree
tree Time Limit: 8000ms Memory Limit: 262144KB This problem will be judged on HDU. Original ID: 5390 ...
随机推荐
- 关于npm警告fsevents和vue-cli项目中的一些问题,持续更新
1.install一个npm包的时候,总是会报这个警告: 网上查资料知道,这个fsevents是mac下用的,windows忽略即可: 2.关于在main.js中引入less文件的问题, 就会报这个错 ...
- linux内核(四)内存管理单元MMU
1,基本概念 一个程序运行时没必要全部都同时装入内存,只需要把当前需要运行的部分装入内存即可,这样就使得一个大程序可以在较小的内存中运行,也使得内存中可以同时装入更多的程序并发执行,从用户角度看,该系 ...
- DataTables warning: table id=dataTable - Requested unknown parameter 'acceptId' for row 0. For more
重点内容 DataTables warning: table id=dataTable - Requested unknown parameter 'acceptId' for row 0. For ...
- Android Parcelable vs Serializable
序列化 在Android中.对象在实现序列化之前是无法直接作为Intent參数在Activity之间传递的. Android中对象序列化能够通过实现Serializable接口或者实现Parcelab ...
- FireEye APT检测——APT业务占比过重,缺乏其他安全系统的查杀和修复功能
摘自:https://zhidao.baidu.com/question/1694626564301467468.html火眼,APT威胁下快速成长 FireEye的兴起开始于2012年,这时段正好迎 ...
- nyoj--18--The Triangle(dp水题)
The Triangle 时间限制:1000 ms | 内存限制:65535 KB 难度:4 描述 7 3 8 8 1 0 2 7 4 4 4 5 2 6 5 (Figure 1) Figure ...
- c:\Windows\System32\drivers\etc\hosts的作用
c:\Windows\System32\drivers\etc\hosts 是域名解析文件. 可以直接用记事本打开.将IP地址重定向. 格式为:ip地址-空格-域名 可以将一个域名重新定向到一个IP ...
- js捕获页面回车事件
1.javascript版 document.onkeyup = function (e) { if (window.event)//如果window.event对象存在,就以此事件对象为准 e = ...
- 17.广度优先遍历bfs
#include <iostream> #include <boost/config.hpp> //图(矩阵实现) #include <boost/graph/adjac ...
- shiro动态控制url资源
怎么利用shiro权限动态控制每个url资源呢?主要包括jsp(html)页面.action的url访问,而静态资源和登录资源则可直接访问. 所谓动态控制url就是url的权限控制不是手动写死在配置文 ...