谨以此题纪念边界测试数据浪费了我多少时间: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. Tomcat 管理监控工具

    本文链接:https://blog.csdn.net/weixin_34364071/article/details/86753232 专注于Java领域优质技术号,欢迎关注 原创: 侯树成 Tomc ...

  2. NGUI: Next-Gen UI 2018.3.0f

    https://assetstore.unity.com/packages/tools/gui/ngui-next-gen-ui-2413 NGUI is a very powerful UI sys ...

  3. Centos7修改为固定IP后 yum 出现could not retrieve mirrorlist

    Centos7修改为固定IP后 yum 出现could not retrieve mirrorlist,发现yum源的域名无法解析 按照6,修改/etc/resovle.conf,新增域名解析服务器1 ...

  4. Hive跨集群迁移

    Hive跨集群迁移数据工作是会出现的事情, 其中涉及到数据迁移, metastore迁移, hive版本升级等. 1. 迁移hdfs数据至新集群hadoop distcp -skipcrccheck ...

  5. 000 centos7下安装elasticsearch7的单节点安装

    在这里,直接使用最新的包进行学习.这里的安装也以前的版本不同,不过因为学习,这部分安装的区别不具体研究了. 这里也是摸索型的记录,所以会出现报错情况,然后针对这种方式进行解决,最后达到安装完成的效果. ...

  6. Vehicle routing with Optaplanner graph-theory

    Vehicle routing with Optaplanner - Stack Overflow https://stackoverflow.com/questions/22285252/vehic ...

  7. VsCode写Python代码!这代码简直和大神一样规范!太漂亮了!

    VsCode写Python代码!这代码简直和大神一样规范!太漂亮了!    转 https://www.jianshu.com/p/636306763d89 VsCode虽然没有Pycharm的功能齐 ...

  8. 一起入门Python2之python的安装及初识

    鉴于论坛需要持续更新文章才能更好的保证论坛的访问量和质量,以及论坛的发展.承蒙前辈的信任和支持,我就教大家python第二课,教的不好请多担待和指正. 我们先讲python的安装方法: 方法链接:ht ...

  9. Python初级 3 基本数学运算

    一. 四大基本运算操作符 1 加+ print(3 + 2) 2 减- print(3 - 2) 3 乘:* print(3 * 2) 4 除/, // print(3 / 2) print(3 // ...

  10. ubuntu14.0.4安装kafka

    1. 下载 zookeeper-3.4.12 zookeeper download 2 配置Zookeeper 进入 zookeeper 的 conf 目录下,找到 zoo_sample.cfg 文件 ...