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 ...
随机推荐
- 编码 - 坑 - win10 下采用 utf-8, 导致 gitbash 中文字体异常, 待解决
blog01 概述 使用 git 中, 遇到一个坑 背景 最近遇到一个 编码转换 问题 本来也 一知半解 要是有人能给我讲讲就好了 环境 win10 1903 git 2.20.1 1. 问题 概述 ...
- Centos7在防火墙中添加访问端口
1. 查看jenkins启动状态命令:systemctl status Jenkins 保证jenkins启动,此处的状态为正在运行 2. 查看防火墙状态命令:systemct ...
- DM642学习:CMD、GEL文件
在建立ccs工程的时候,cmd文件和gel文件非常重要,如不能配置好会出现一些莫名其妙的问题. 1. CMD文件: 不同的DSP芯片内集成的存储器大小各异,但其配置方式是类似的.大家可通过查阅DSP芯 ...
- spring bean 的作用域
spring bean 的作用域: 1.单例(singleton):默认是单例模式,也就是说不管给定的bean被注入到其他bean多少次,注入的都是同一个实例. 2.原型(prototype):每次注 ...
- c# 技巧
1 遍历属性 Type t = typeof(Colors); PropertyInfo[] pInfo = t.GetProperties(); foreach (PropertyInfo pi i ...
- Android开发模拟器(虚拟机)的连接等操作
前10天一直在解决android开发环境的问题,我将Androidstudio下载并安装好之后,进入IDE之后,下载AVDmanger中的虚拟机以及SDK等等.之后发现并不能运行虚拟机,根本无法打开虚 ...
- 拦截导弹类问题 (Codevs4888零件分组POJ1065Wooden Sticks)(LIS及其覆盖问题)
拦截导弹 题意:求最长不上升子序列长度:求一个序列最少分成几个非增子序. 第一问易求,已知序列a,令f[i]为a前i个元素的最长非增子序的长度,则有 f[i]=max{f[i],f[j]+1} (1& ...
- SpringBoot获取http请求参数的方法
SpringBoot获取http请求参数的方法 原文:https://www.cnblogs.com/zhanglijun/p/9403483.html 有七种Java后台获取前端传来参数的方法,稍微 ...
- AC3 encoder flow
AC3 encoder flow 如下: 1.input PCM PCM在进入encoder前会使用high pass filter来移除信号的DC部分来达到更有效的编码. 2.Transient d ...
- input file弹出框选择文件后缀限制
在页面选择文件时的弹出框默认显示的是所有类型的文件,有时候文件太多不好选择,我们就要过滤掉不想展示的文件,这是需要用到input的accept属性,只有在type="file"才有 ...