谨以此题纪念边界测试数据浪费了我多少时间:https://pintia.cn/problem-sets/994805342720868352/problems/994805507225665536

 #include <iostream>
#include <string>
#include <vector>
#include <algorithm> void read(std::vector<int>& _data)
{
std::string s;
std::cin >> s;
_data.reserve(s.size());
for (auto c : s)
if (c < 'a')
_data.push_back(c - '');
else
_data.push_back(c - 'a' + );
} auto convert(const std::vector<int>& _data, uint64_t _radix)
{
uint64_t res = ;
for (auto i : _data)
res = res * _radix + i;
return res;
} uint64_t solve(const std::vector<int>& _data, uint64_t _value)
{
if (_data.size() == )
return _data[] == _value ? _value + : -;
uint64_t radix;
for (radix = ; convert(_data, radix) <= _value; radix *= )
;
if (radix == )
return -;
auto begin = std::max<uint64_t>(*std::max_element(_data.begin(), _data.end()) + , radix / );
auto end = radix;
while (begin < end)
{
auto mid = (begin + end) / ;
auto res = convert(_data, mid);
if (res > _value)
end = mid;
else if (res < _value)
begin = mid + ;
else
return mid;
}
return -;
} int main(int argc, char const *argv[])
{
std::vector<int> data;
int64_t value;
{
std::vector<int> source;
read(source);
read(data);
int which;
std::cin >> which;
if (which == )
source.swap(data);
int radix;
std::cin >> radix;
value = convert(source, radix);
} auto res = solve(data, value);
if (res == -)
std::cout << "Impossible";
else
std::cout << res; return ;
}

1010 Radix:猥琐的测试数据的更多相关文章

  1. PHP后门新玩法:一款猥琐的PHP后门分析

    0x00 背景 近日,360网站卫士安全团队近期捕获一个基于PHP实现的webshell样本,其巧妙的代码动态生成方式,猥琐的自身页面伪装手法,让我们在分析这个样本的过程中感受到相当多的乐趣.接下来就 ...

  2. PAT 解题报告 1010. Radix (25)

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

  3. Finding Palindromes - 猥琐的字符串(Manacher+trie)

    题目大意:有 N 个字符串,所有的字符串长度不超过 200W 任意俩俩字符串可以自由组合,问组合的字符串是回文串的个数有多少个?   分析:这是一个相当猥琐的字符串处理,因为没有说单个的字符串最少多长 ...

  4. 1010 Radix (25 分)

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

  5. 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 ...

  6. PAT甲级1010. Radix

    PAT甲级1010. Radix (25) 题意: 给定一对正整数,例如6和110,这个等式6 = 110可以是真的吗?答案是"是",如果6是十进制数,110是二进制数. 现在对于 ...

  7. pat 甲级 1010. Radix (25)

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

  8. delphi之猥琐的webserver实现

    http://www.birdol.com/cainiaobiancheng/238.html delphi之猥琐的webserver实现 菜鸟编程  十五楼的鸟儿  7年前 (2009-01-01) ...

  9. PAT 1010 Radix(X)

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

随机推荐

  1. JVM相关文章和GC原理算法

    参考推荐: Java内存模型及GC原理 一个优秀的Java程序员必须了解的GC机制 Android 智能指针原理(推荐) Java虚拟机规范 Java虚拟机参数 Java内存模型 Java系列教程(推 ...

  2. google chrome 浏览器插件

    如果感觉浏览器(chrome)的背景是白色太亮太刺眼,可以先在 设置->外观->主题背景 里选择 oceanic,将浏览器头部颜色设置为海蓝色.然后再安装插件 “眼睛护航”,改变所有网页的 ...

  3. Makefile教程(绝对经典,所有问题看这一篇足够了)【转】

    该篇文章为转载,是对原作者系列文章的总汇加上标注. 支持原创,请移步陈浩大神博客: http://blog.csdn.net/haoel/article/details/2886 makefile很重 ...

  4. win10创建Ubuntu16.04子系统,安装常用软件以及图形界面(包括win10远程桌面连接Ubuntu)

    一.开启win10子系统 [ Windows Subsystem for Linux(WSL)] 二.基本配置 三.安装常用的软件 安装配置zsh 使用 bash 客户端软件 cmder(其实是win ...

  5. PHPStorm提示:phpdoc comment doesn't contain all necessary @throw tag(s)

    选择Settings => Editor => Inspection, 选择PHP => PHPDoc => Missing @throws tag(s) ,把后面的勾勾去掉就 ...

  6. [转]3D渲染管线

    转自:http://tgerm.org/SRP/ 在3D中有两种渲染管线,分别是图形渲染管线和GPU渲染管线. 图形渲染管线 <Render-Time Rendering Third Editi ...

  7. 数据分析入门——IPython入门

    一.什么是IPython IPython的开发者吸收了标准解释器的基本概念,在此基础上进行了大量的改进,创造出一个令人惊奇的工具.在它的主页上是这么说的:“这是一个增强的交互式Python shell ...

  8. 【Linux】宝塔上 GitLab数据迁移修改配置后nginx无法启动

    背景: 服务器A 向 服务器B 迁移数据,修改配置重启.发现gitlab的 nginx 无法启动. 查找原因 gitlab-ctl tail 错误信息: 网上查了查,似乎是宝塔的问题, 原因应该是为了 ...

  9. 【笔记】第六章、Linux 的文件权限与目录配置

    Linux的每个文件中,依据权限分为使用者.群组与其他人三种身份: 群组最有用的功能之一,就是当你在团队开发资源的时候,且每个账号都可以有多个群组的支持: 利用ls -l显示的文件属性中,第一个字段是 ...

  10. CentOS7 配置sendmial + PHP mail函数发送邮件

    https://blog.csdn.net/jiabangok/article/details/51840556