https://pintia.cn/problem-sets/994805342720868352/problems/994805507225665536
注意: 答案可能不是[2,36] 而是一个非常大的数
确定的数最大可能为: zzzzzzzzzz(36) 约为3610等于3,656,158,440,062,976<1e18 不会爆long long的

#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long int LL;
string a,b,k;
int d;
LL get(char a) {return a<='9'?a-'0':a-'a'+10;} //获取当前位的数字
LL D(string s,LL d)//d转换成10进制
{LL sum=0;for(int i=0;i<s.size();i++) {if((double)sum>(1e18*1.0-get(s[i]))/d) return 1e18;//数已经超1e18了直接返回1e18即可 sum=sum*d+get(s[i]);}return sum;
}
bool check(string a,string b,int d)
{LL sum=D(a,d);LL l=0,r=1e12;//最坑的一个点7,答案是爆int的 for(LL i=0;i<b.size();i++) l=max(l,get(b[i]));l=l+1;while(l<r){LL mid=l+r>>1;LL temp=D(b,mid);if(temp>=sum) r=mid;else l=mid+1;}if(D(b,l)!=sum) return false;cout<<l<<endl;return true;
}
int main(void)
{cin>>a>>b>>k>>d;if(k=="1"&&check(a,b,d)) return 0; if(k=="2"&&check(b,a,d)) return 0;cout<<"Impossible";return 0;
}

1010 Radix (25 分)【难度: 难 / 知识点: 二分查找】相关推荐

  1. 【测试点分析】1010 Radix (25 分)_37行代码AC

    立志用最少的代码做最高效的表达 PAT甲级最优题解-->传送门 Given a pair of positive integers, for example, 6 and 110, can th ...

  2. 1010 Radix (25 分)

    一.问题描述 输入两个数N1.N2,和一个标记tag.一个基数radix,其意义是:tag为1时,radix是N1的基数:tag为2时,radix是N2的基数.方便起见,以下假定tag为1,则目标就是 ...

  3. PAT Advanced—1010 Radix (25分)

    Given a pair of positive integers, for example, 6 and 110, can this equation 6 = 110 be true? The an ...

  4. 1066 Root of AVL Tree (25 分)【难 / 知识点: 平衡树 未完成】

    https://pintia.cn/problem-sets/994805342720868352/problems/994805404939173888 平衡树之前学过,不过有忘完了,有时间补吧

  5. pat 甲级 1010. Radix (25)

    1010. Radix (25) 时间限制 400 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue Given a pair of ...

  6. [Java] 1010. Radix (25)-PAT甲级

    1010. Radix (25) Given a pair of positive integers, for example, 6 and 110, can this equation 6 = 11 ...

  7. c语言分蛋糕均匀正方形,分蛋糕(C - 二分查找)

    分蛋糕 题目链接:http://acm.hust.edu.cn/vjudge/contest/view.action?cid=85904#problem/C Description My birthd ...

  8. 【PAT - 甲级1010】Radix (25分)(二分,进制转化)

    题干: Given a pair of positive integers, for example, 6 and 110, can this equation 6 = 110 be true? Th ...

  9. 1150 Travelling Salesman Problem (25 分)【难度: 难 / 知识点: 图 模拟 未完成】

    https://pintia.cn/problem-sets/994805342720868352/problems/1038430013544464384

最新文章

  1. C#实现数据回滚,A事件和B事件同时执行,其中任何一个事件执行失败,都会返回失败...
  2. LVS+OSPF 架构
  3. 82 个代码案例实践,带你学好 Python 机器学习
  4. 【二分】Best Cow Fences(poj 2018)
  5. [c++基础] const char and static const char
  6. linux命令行配置代理_Linux命令行乐趣,顶级配置工具,Kubeflow等
  7. JavaScript事件处理程序的3种方式
  8. rs232接口_、 迪文串口屏TTL与主控板RS232电平信号转换方案
  9. Nginx(一):Nginx介绍
  10. mysql 非英文_非英文网站如何使用MySQL的字符集
  11. Linux 内核第一宏
  12. freeswitch 基于webrtc网页视频、语音通话官方例子video_demo安装
  13. 540.有序数组中的单一元素(力扣leetcode) 博主可答疑该问题
  14. python ImportError: cannot import name Template解决方法
  15. VB 2008下载地址
  16. 儒略日 (Julian Date)
  17. mysql数据库安装过程蜿蜒曲折
  18. 如何制定人生目标体系
  19. JDBC增删改查练习案例
  20. 转换工具推荐:如何将PDF文档转换为PPT演示文稿

热门文章

  1. java数据结构至对称矩阵压缩存储
  2. Ubuntu16.04 Docker 安装
  3. python---tornado钩子预留解析
  4. 【转】最小编辑距离 算法原理
  5. mysql中timestamp类型数据查找中出现的问题
  6. STM32:Flash擦除与读写操作(HAL库)
  7. 关于点击率模型,你知道这三点就够
  8. python中将字符变为大写_Python笔记(一)
  9. 设计模式总结 (5)行为型模式续
  10. 《研磨设计模式》chap14 迭代器模式(1)简介