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 ...
随机推荐
- 谷歌浏览器安装jsonview
1.下载JsonView扩展程序压缩包 下载链接:https://pan.baidu.com/s/1B0IkrHHyTiYtwJEGE_halA 提取码:myi6 2.解压这个压缩包 3.打开谷歌浏览 ...
- 【转】Error,java对常量池来说字符串xxx的UTF8表示过长的解决及其理解
做项目,客户端这里自己模拟json数据时,一时没忍住搞得json字符串太长了(idea上大概有600多行吧),这个问题就蹦出来了.老方法直接google.百度然后看到一堆有关String 字符串常量池 ...
- (转)http 之session和cookie
http://www.cnblogs.com/xuxm2007/archive/2011/12/05/2276705.html Session简介 摘 要:虽然session机制在web应用程序中被采 ...
- memcached和redis对比
关于memcached和redis的使用场景,总结如下:两者对比: redis提供数据持久化功能,memcached无持久化. redis的数据结构比memcached要丰富,能完成场景以外的事情: ...
- MFC对话框常用操作文章收藏
1.改变控件文本 参考链接:https://blog.csdn.net/active2489595970/article/details/88856235 所有控件的文本都可以用这种方式动态改变. 2 ...
- ts中接口的用法
ts中的接口主要的作用是: 对“对象”进行约束描述 对“类”的一部分行为进行抽象 一.属性接口 接口中可定义 确定属性.可选属性.任意属性.只读属性 1.确定属性 interface UserInfo ...
- MySQL中int(11)的意思
参考文献:https://segmentfault.com/a/1190000012479448 int(11)中的11代表的是字符的显示宽度,在字段类型为int时,无论你显示宽度设置为多少,int类 ...
- AcWing 792. 高精度减法
https://www.acwing.com/problem/content/794/ #include<bits/stdc++.h> using namespace std; //判断是 ...
- 矩阵快速幂 裸 hdu1575
裸题,求A^n次后的对角线数字之和 #include<cstdio> #include<algorithm> #include<string.h> using na ...
- day14 find
find命令查找信息补充 查看找文件数据信息: 精确查找: find 路径信息 -type 文件类型 -name "文件名" 模糊查找: find 路径信息 -type 文件类型 ...