谨以此题纪念边界测试数据浪费了我多少时间: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. python技巧获取26个英语字母

    import string string.ascii_uppercase # 获取26个大写字母 string.ascii_lowercase # 获取26个小写字母 string.ascii_let ...

  2. PHP如何解决网站大流量与高并发的问题(四)

    动态语言的并发处理 相关概念 什么是进程.线程.协程 什么是多进程.多线程 同步阻塞模型 异步非阻塞模型 php并发编程实践 什么是进程.线程.协程 进程 进程是一个执行中的程序 进程的三态模型:多道 ...

  3. Linux-IIC驱动(详解)

    IIC接口下的24C02 驱动分析: http://www.cnblogs.com/lifexy/p/7793686.html 接下来本节, 学习Linux下如何利用linux下I2C驱动体系结构来操 ...

  4. SQL中join和cross join的区别

    SQL中的连接可以分为内连接,外连接,以及交叉连接 . 1. 交叉连接CROSS JOIN 如果不带WHERE条件子句,它将会返回被连接的两个表的笛卡尔积,返回结果的行数等于两个表行数的乘积: 举例, ...

  5. windows下jenkins的安装与配置

    项目自动化部署: https://www.cnblogs.com/wuxunyan/p/9592953.html https://blog.csdn.net/qq_37372007/article/d ...

  6. h2的时间类型和函数

    H2时间类型: (时间)TIME: 格式为 hh:mm:ss.对应到Java类型:java.sql.Time. (日期)DATE: 格式为 yyyy-MM-dd.对应到Java类型: java.sql ...

  7. (E2E_L2)GOMfcTemplate在vs2017上的运行并融合Dnn模块

    GOMfcTemplate一直运行在VS2012上运行的,并且开发出来了多个产品.在技术不断发展的过程中,出现了一些新的矛盾:1.由于需要使用DNN模块,而这个模块到了4.0以上的OpenCV才支持的 ...

  8. openresty开发系列15--lua基础语法4表table和运算符

    openresty开发系列15--lua基础语法4表table和运算符 lua中的表table 一)table (表)Table 类型实现了一种抽象的"关联数组".即可用作数组,也 ...

  9. realsense d435i問題太多了

    Selecting Windows SDK version 10.0.17134.0 to target Windows 10.0.18362. Internet connection identif ...

  10. osg gdal加载tif数据文件

    osg加载.tif地形数据文件 #ifdef _WIN32 #include <Windows.h> #endif // _WIN32 #include <iostream> ...