1010 Radix (25分)
改了一天也没明白,第7个数据是怎么卡的
#include <bits/stdc++.h>
using namespace std;
const int maxn=1005;
typedef long long ll;
ll tonum(char c)
{
if (c>='0'&&c<='9') {
return c-'0';
}
return c-'a'+10;
}
long long tran(string s,ll base)
{
int len=s.length();
ll res=0;
for (int i=0;i<len;i++) {
res=res*base+tonum(s[i]);
}
return res;
}
int main()
{
int tag,base;
string a,b;
cin>>a>>b>>tag>>base;
if (tag==2) {
swap(a,b);
}
ll numa=tran(a,base);
ll left=2,right=numa+1;
int len=b.length();
for (int i=0;i<len;i++) {
left=max(left,tonum(b[i])+1);
}
// printf("%lld %lld\n",left,right);
while (left<=right) {
ll mid=(right+left)>>1;
// printf("%lld\n",mid);
ll t=tran(b,mid);
if (t<0||t>=numa) right=mid-1;
else left=mid+1;
}
if (tran(b,left)==numa) {
printf("%lld\n",left);
}
else {
printf("Impossible");
}
return 0;
}
1010 Radix (25分)的更多相关文章
- 1010 Radix (25 分),PTA
题目:https://pintia.cn/problem-sets/994805342720868352/problems/994805507225665536 题意:给定n1.n2两个数,求可以是两 ...
- 1010 Radix (25 分)
Given a pair of positive integers, for example, 6 and 110, can this equation 6 = 110 be true? The an ...
- PAT Advanced 1010 Radix(25) [⼆分法]
题目 Given a pair of positive integers, for example, 6 and 110, can this equation 6 = 110 be true? The ...
- PAT 1010 Radix (25分) radix取值无限制,二分法提高效率
题目 Given a pair of positive integers, for example, 6 and 110, can this equation 6 = 110 be true? The ...
- 【PAT甲级】1010 Radix (25 分)(二分)
题意: 输入两个数可能包含小写字母,1或者2,进制大小.第三个数为代表第一个数是第四个数进制的,求第二个数等于第一个数时进制的大小,不可能则输出Impossible,第三个数为2代表第二个数是第四个数 ...
- PAT 甲级 1010 Radix (25)(25 分)进制匹配(听说要用二分,历经坎坷,终于AC)
1010 Radix (25)(25 分) Given a pair of positive integers, for example, 6 and 110, can this equation 6 ...
- PAT 解题报告 1010. Radix (25)
1010. Radix (25) Given a pair of positive integers, for example, 6 and 110, can this equation 6 = 11 ...
- pat 甲级 1010. Radix (25)
1010. Radix (25) 时间限制 400 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue Given a pair of ...
- 1010. Radix (25)(未完成)
Given a pair of positive integers, for example, 6 and 110, can this equation 6 = 110 be true? The an ...
随机推荐
- JMeter概念
1. Test Plan 测试计划 Test Plan也就是测试计划,概念有点类似eclipse里面的project(项目.工程). 一个JMeter测试计划有很多种测试元素组成.一般至少包含一个T ...
- python的selenium实现自动登陆
知道思想,参考其他文档,python的request模块和selenium模块都可以实现get_cookie()和 add_cookie()的功能. 由于现在在学习selenium自动化测试,我选用s ...
- Echat 地图样式格式
1.白色 mapStyle: { styleJson: [{ 'featureType': 'water', 'elementType': 'all', 'stylers': { 'color': ' ...
- python pymysql 基本使用
from pymysql import * # 1.创建连接数据库 conn = connect(host="localhost", port=3306, user="r ...
- javascript 循环读取数组中的值
//数组 var a = ["#F85C6F", "#78B0F0", "#DB83ED", "#8EC656", &q ...
- Python_递归函数
楔子 在讲今天的内容之前,我们先来讲一个故事,讲的什么呢?从前有座山,山里有座庙,庙里有个老和尚讲故事,讲的什么呢?从前有座山,山里有座庙,庙里有个老和尚讲故事,讲的什么呢?从前有座山,山里有座庙,庙 ...
- c#中convert.toInt32和int.parse()和强制类型转换的区别
string a="123"; int i=(int)a; 这是会出现错误因为:强制类型转换只能转换值类型不能转换引用类型 string属于引用类型 强制类型转换时如果值类型 ...
- Jquery动态改变my97datepicker的日期形式
先要解绑触发事件: $('#start').unbind('focus'); 然后再绑定触发事件: $('#start').bind('focus',function(){WdatePicker({s ...
- rancher布控集群启动失败
rancher布控集群启动失败 待办 报告缺少某个文件.多线程启动任务部署的时候某些线程跑在前边了, 导致问题出现 解决思路:等待,等待响应的job重启就ok了,都是一些job在跑,失败了会重新开始的 ...
- 阿里配置docker镜像专属地址
阿里配置docker镜像专属地址 待办 https://www.jianshu.com/p/6b416dff0691