谨以此题纪念边界测试数据浪费了我多少时间: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. adb-andorid记录当前手机的日志当前显示的app进程及activity,

    adb logcat -v time> /home/sumsang.log adb shell dumpsys window | grep mCurrentFocus

  2. Sequence contains no elements

    这个错误,在使用List<T>的First函数遇到. Sequence contains no elements? From "Fixing LINQ Error: Sequen ...

  3. Python 23种设计模式全(python例子)

    从今年5月份开始打算把设计模式都写到博客里,持续到现在总算是写完了.写的很慢,好歹算是有始有终.对这些设计模式有些理解的不准确,有些甚至可能是错的,请看到的同学拍砖留言.内容来源很杂,大部分参考或者摘 ...

  4. leetcode 542. 01 Matrix 、663. Walls and Gates(lintcode) 、773. Sliding Puzzle 、803. Shortest Distance from All Buildings

    542. 01 Matrix https://www.cnblogs.com/grandyang/p/6602288.html 将所有的1置为INT_MAX,然后用所有的0去更新原本位置为1的值. 最 ...

  5. Python之Pandas绘图,设置显示中文问题

    # -*- coding: utf-8 -*- # author:baoshan import pandas as pd import matplotlib.pyplot as plt plt.rcP ...

  6. 004-行为型-06-命令模式(Command)

    一.概述 是一种数据驱动的设计模式 请求以命令的形式包裹在对象中,并传给调用对象.调用对象寻找可以处理该命令的合适的对象,并把该命令传给相应的对象,该对象执行命令. 将请求封装成对象,以便使用不同的请 ...

  7. 002-05-RestTemplate 使用常见问题-非200请求捕获

    一.概述 1.1.RestTemplate报错时时获取不到错误信息 捕获异常后 try { result = restTemplate.postForEntity(faceConfig.getApiU ...

  8. Exception in thread "main" brut.androlib.AndrolibException: Could not decode arsc file at brut.androlib.res.decoder.ARSCDecoder.decode

    使用ApkIDE反编译出现如下错误: Exception in thread "main" brut.androlib.AndrolibException: Could not d ...

  9. osg 渲染ifc数据-测试

    直接使用osg渲染ifc数据,提高渲染速度. #include "teslamanage.h" #include <QtWidgets/QApplication> #i ...

  10. k8s记录-etcd集群部署(三)

    https://blog.csdn.net/fy_long/article/details/86542872 1)程序准备tar xvf etcd-v3.3.11-linux-amd64.tar.gz ...