POJ 1894 Alternative Scale of Notation

国网DLT698.45协议——采集系统、数据交换(三) 物理层规定了通信单元或其他终端设备与多功能电表的通信接口,接口的物理与电气特性。常见的物理层传输方式有对于RS485、红外、载波通信等通信信道。将数据包装成可传输的帧格式。1、根据通信配置参数完成端口的初始化配置,通信状态初始化为准备接收状态,初始化相关计数器及缓冲区指针。2、链路层及控制子模块负责通信数据的收发控制,各类超时问题的处理。无通信数据接收时,定时初始化通信端口。3、完成协议帧的解析及应答。 阅读详情

Alternative Scale of Notation
Time Limit: 1000MS Memory Limit: 30000K
Total Submissions: 1530 Accepted: 538

Description

One may define a map of strings over an alphabet Σ B = { C1, C2, . . . C B } of size B to non-negative integer numbers, using characters as digits C1 = 0, C2 = 1, . . . , C B = B - 1 and interpreting the string as the representation of some number in a scale of notation with base B. Let us denote this map by U B , for a string α[ 1...n ] of length n we put 
UB(α)=Σ0<=i<=n-1α[n-i]*Bi
For example, U3(1001) = 1*27 + 0*9 + 0*3 + 1*1 = 28. 

However, this correspondence has one major drawback: it is not one-to-one. For example, 
28 = U3(1001) = U3(01001) = U3(001001) = ... , 
infinitely many strings map to the number 28. 

In mathematical logic and computer science this may be unacceptable. To overcome this problem, the alternative interpretation is used. Let us interpret characters as digits, but in a slightly different way: C1 = 1, C2 = 2, . . . , C B = B . Note that now we do not have 0 digit, but rather we have a rudiment B digit. Now we define the map V B in a similar way, for each string α[ 1...n ] of length n we put 
VB(α)=Σ0<=i<=n-1α[n-i]*Bi
For an empty string ε we put V B(ε) = 0. 

This map looks very much like U B , however, the set of digits is now different. So, for example, we have V3(1313) = 1*27 + 3*9 + 1*3 + 3*1 = 60. 

It can be easily proved that the correspondence defined by this map is one-to-one and onto. Such a map is called bijective, and it is well known that every bijective map has an inverse. Your task in this problem is to compute the inverse for the map V B . That is, for a given integer number x you have to find the string α, such that V B(α) = x. 

Input

The first line contains B (2 <= B <= 9) and the second line contains an integer number x given in a usual decimal scale of notation, 0 <= x <= 10 100.

Output

Output in one line such string α, consisting only of digits from the set { 1, 2, . . . , B }, that V B(α) = x . 

Sample Input

3
60

Sample Output

1313

Source

/*

第一次在POJ上用JAVA提交程序,一开始用自己写的大数运算工具库做的,结果TLE,后来转用JAVA的BIG INTEGER就过了

看来自己写的那个大数运算工具还是只适合做工程,不适合来做ACM的题啊。下面分别给出C++(TLE)和JAVA(ACCPET)版本

其实思路很简单:

对于U串[Un, Un-1, Un-2, ..., U1]其对应的V串是[Un + 1, Un-1 + 1, Un-2 + 1,..., U1 + 1]即在每一个U串元素的基础上+1

那么U串的X值和V串的X值是什么关系呢? xV = Bn * (Un + 1) + Bn-1 * (Un-1 + 1) + Bn-2 * (Un-2 + 1) +... + B1 * (U1 + 1)

其中Bn = base ^ (n - 1). 则xV = xU + Bn + Bn-1 + Bn-2 +  ... + B1,所以可以基于以下步骤通过间接求U串来求解V串:

1)将输入x迭代减去bi,当bi > x时退出,此时剩下的x为U的x值,并记录下迭代的步骤len,len即为V串的长度

2)利用10进制转base进制的方法在1)中x的基础上求U串

3)2)中出的U串的长度l很可能小于Len,则在U串前面补齐Len - l个0

4)一次输出U串元素+1即为V串

*/


import java.io.BufferedInputStream;
import java.math.BigInteger;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner cin = new Scanner(System.in);  
        BigInteger base = null, input = null;
        BigInteger zero = BigInteger.valueOf(0);
        String res = "";
        while(cin.hasNextBigInteger())
        {
            base = cin.nextBigInteger();
            input = cin.nextBigInteger();
            if(input.compareTo(zero) == 0) continue;
            //System.out.println("hell0");
            BigInteger cur = BigInteger.valueOf(1);
            int len = 0;
            while(input.compareTo(cur) >= 0)
            {
                len++;
                input = input.subtract(cur);
                cur = cur.multiply(base);
            }
            res = "";
            BigInteger residual = null;
            BigInteger quotient = null;
            while(input.compareTo(zero) != 0)
            {
                quotient = input.divide(base);
                residual = input.mod(base);
                input = quotient;
                res = residual.toString() + res;
            }
            int l = res.length();
            while(l < len)
            {
                res = "0" + res;
                l++;
            }
            for(l = 0; l < res.length(); l++)
                System.out.print((char)(res.charAt(l) + 1));
        }
        
    }
}

Qt —— 百度离线地图 - 加载百度离线地图、及地图上绘图(附:源码) Qt —— 加载百度离线地图、及简单绘图(附源码) 阅读详情

相关推荐

数学建模 种群竞争模型 学习笔记

模型背景 应用场景 种群竞争模型 例如 s1=0.5,则表示对于供养甲的资源来讲,单位数量的乙的消耗为单位数量的甲的0.5倍,即表示乙对于该资源的占有能力是甲的0.5倍(即竞争力弱) 仿真结果及分析 (1)设置自然增长率 r1=r2=1 (2)改变自然增长率 r1=r2=0.3 (3)修改甲和乙的最大容量 n1=10000, n2=100 (4)修改甲和乙的初始数量 x1=10, x...

Test_tju的博客 2028

poj 超详细分类

POJ各题算法

liangkk的博客 1万+

Mac终端SSH连接腾讯云服务器保姆级教程(附秘钥管理技巧)

本文提供Mac终端SSH连接腾讯云服务器的详细教程,涵盖密钥生成、权限设置、连接优化及高级管理技巧。通过清晰的步骤和实用配置,帮助用户安全高效地管理远程服务器连接,特别适合开发者和运维人员参考。

weixin_29248313的博客 456

POJ 1894 Alternative Scale of Notation

给一个Base,一个大整数(100位),求这个大整数的Base进制的表示,其中,表示中不能出现0,但是可以出现Base。 如,60 = 1 * 3^3 + 3 * 3^2 + 1 * 3^1 + 3 * 3^0,所以,60(3) = 1313。 思路: 依然是,让大整数不断地对Base取模得到低位,再对Base做整数除法,不一样的是如果得到的模是0,那么低位会是Base,而不是0。 涉及到

jasison 601

激光雷达接收芯片选型指南:APD、SiPM、SPAD阵列的优缺点对比

本文深入对比了激光雷达接收芯片APD、SiPM和SPAD阵列的核心技术原理与性能差异。APD作为线性模式工作的稳健选择,动态范围大;SiPM具备单光子探测和高增益优势;而SPAD阵列凭借像素级数字读出和集成TDC,在时间分辨率与系统集成度上领先。文章从灵敏度、时间精度、动态范围及系统成本等多维度剖析,为不同应用场景(如车载雷达、Flash LiDAR、消费电子)的芯片选型提供实战指南。

ik6789012的博客 656

Unity游戏开发客户端面经——设计模式(初级)

Unity游戏开发客户端面经 之 设计模式 篇

Sea3752的博客 9431

Alternative Scale of Notation(大数java)

import java.util.*; import java.io.*; import java.math.*; import java.text.*; public class not { public static void main(String args[]) { BigInteger b,x,t,tt; int len,i,k; Scanner cin=new

林下的码路 962

别再折腾虚拟机了!手把手教你用WSL2在Windows 11上安装Kali Linux(含汉化与图形界面)

本文详细介绍了如何在Windows 11上通过WSL2安装和配置Kali Linux,包括汉化与图形界面设置。通过WSL2,用户可以享受接近原生性能的Linux体验,同时保持与Windows系统的无缝集成,特别适合网络安全爱好者和开发者。文章还提供了常见问题解决和性能优化建议,帮助用户高效使用Kali工具集。

weixin_42525369的博客 322

POJ 1894 Alternative Scale of Notation .

题目地址:http://poj.org/problem?id=1894import java.util.*; import java.math.*; import java.text.*; import java.io.*; public class Main { public static void main(String[] args) { Scanner cin = new Sca

BRCOCOLI的博客 299

Hypack 应用于地形测量的高级设置操作要领

Hypack 是业界公认最好的水文导航测量软件,是目前世界上应用广泛的专业测量疏浚软件。它能够接收,处理,存储和输出各种数据。Hypack支持绝大部分GPS,测深仪(国内如海鹰HY1603单波束测沙仪),多波束测深仪,旁扫声纳,涌浪补偿器,水位仪,验潮仪以及声速剖面仪。利用 Hypack 可以进行导航,单波束测量,多波束测量,旁扫测量以及疏浚实时监测等。软件界面友好,使用方便。本文简要阐述Hypack 应用于地形测量的几个重要操作要领。

中游鱼的博客 2799

OpenCV计算机视觉实战(11)——边缘检测详解

在本节中,我们系统介绍了三大经典边缘检测算子,包括 Sobel 算子:一阶导数平衡了噪声抑制与边缘提取,结合方向信息可用于纹理分析与车道检测;Laplacian 算子:二阶导数对微小亮度突变尤为敏感,配合零交叉和细化技术,可精确捕捉任意方向的细节边缘;Canny 算法:集成多阶段处理与双阈值策略,通过多尺度融合与自适应阈值优化,达到抗噪与细节兼顾的卓越效果。

qq_30167691的博客 4375

poj 1894 Alternative Scale of Notation

Alternative Scale of NotationTime Limit: 1000MS Memory Limit: 30000KTotal Submissions:2182 Accepted: 808DescriptionOne may define a map of strings over an alphabet ΣB = { C1, C2, . . . CB } of size B ...

superkunn的博客 217

手把手教您windows如何正确的开启局域网共享,如何解决“没权限、空密码访问等诸多问题”,含手动操作教程 + 傻瓜式一键设置工具(局域网共享+打印机管理),二选一总有一款能满足您!

😫 Windows共享总失败?别抓狂!这篇教程带你破解“空密码”访问的核心难题 🔑,四步搞定所有设置。文末还附赠“一键修复”神器 🚀,让文件共享丝滑如德芙!

XiaoqiangClub的博客 1453

POJ 1899 Farmer Bill's Problem

 Farmer Bills ProblemTime Limit: 1000MS Memory Limit: 30000KTotal Submissions: 2159 Accepted: 514DescriptionIt is rumored that the planet Earth is often visited

bobten2008的专栏 994

假人有限元模型

假人模型,车辆碰撞假人有限元模型,适合做乘员安全的研究者利用

C# WinForm 基于DirectShow.dll编写的程序,可边预览边保存视频,音频和图片

基于微软的DirectShow.dll的二次开发1.自动识别连接的摄像头跟麦克风且可以对其进行选择(默认选中第一个)2.可录制wmv和avi两种格式的视频并且都带有音频,avi可以录制的分辨率和帧数进行选择,wmv默认进行了淸晰度优化如不喜欢可去除代码中有相关提示3.可在预览点开之后进行拍照,也可边录制视频边拍照4.添加了视频和音频的压缩功能(酌情使用)这次二次开发发现C#对DirectShow的相关信息太少,这次做完也不敢藏私共享出来,还望大家指正

POJ1894 JAVA高精度水

这两天都在找JAVA高精度的题做,主要是想偷懒,而且JAVA确实做ACM很强大,所以就多练练JAVA做题。 A了好几道水题,这道也挺水,结果读题读错了!!唉呀 ,英语是硬伤啊。。。 题意:进制转换,但将0的部分去掉用进制数来表示。 思路很简单,看代码就行了。结果因为读错题花了一晚上的代价。。。 import java.math.*; import java.util.*; ...

weixin_34240520的博客 136

visio安装包

Microsoft Office Visio 是一款专业的制图软件。利用经过更新的形状、协作工具和数据链接图表,创建专业级图表以简化复杂的信息。

POJ 3977(枚举+二分)

Subset Time Limit: 30000MS   Memory Limit: 65536K Total Submissions: 3295   Accepted: 594 Description Given a list of N integers with absolute values no larger than 101

MR CODER 362

jre9下载 jdk9

(Java SE Runtime Environment 9.0) 9.0u175 官方最新版 【x86|x64】

POJ 1091 跳蚤

 跳蚤Time Limit: 1000MS Memory Limit: 10000KTotal Submissions: 3977 Accepted: 1002DescriptionZ城市居住着很多只跳蚤。在Z城市周六生活频道有一个娱乐节目。一只跳蚤将被请上一个高空钢丝的正中央。钢丝很长,可以看作是无限长。节目主持人会给该

bobten2008的专栏 5277

POJ 1811 Prime Test

Prime TestTime Limit: 6000MS Memory Limit: 65536KTotal Submissions: 15434 Accepted: 2909Case Time Limit: 4000MSDescriptionGiven a big integer number, you are

bobten2008的专栏 2352

POJ 1090 Chain 递推 + 大数加法

 ChainTime Limit: 1000MS Memory Limit: 10000KTotal Submissions: 2025 Accepted: 684DescriptionByteland had not always been a democratic country. There were also bl

bobten2008的专栏 2348

POJ 1930 Dead Fraction

 Dead FractionTime Limit: 1000MS Memory Limit: 30000KTotal Submissions: 1198 Accepted: 354DescriptionMike is frantically scrambling to finish his thesis at the la

bobten2008的专栏 2000

POJ 1715 Hexadecimal Numbers

 Hexadecimal NumbersTime Limit: 1000MS Memory Limit: 10000KTotal Submissions: 1489 Accepted: 347DescriptionThe base of the hexadecimal system is 16. In order to w

bobten2008的专栏 1370

POJ 1142 Smith Numbers

 Smith NumbersTime Limit: 1000MS Memory Limit: 10000KTotal Submissions: 7141 Accepted: 2505DescriptionWhile skimming his phone directory in 1982, Albert Wilansky,

bobten2008的专栏 1332

POJ 1730 Perfect Pth Powers

Perfect Pth PowersTime Limit: 1000MS Memory Limit: 10000KTotal Submissions: 9722 Accepted: 2139DescriptionWe say that x is a perfect square if, for some integer b,

bobten2008的专栏 1243

POJ 1152 An Easy Problem

 An Easy Problem!Time Limit: 1000MS Memory Limit: 10000KTotal Submissions: 6264 Accepted: 1429DescriptionHave you heard the fact "The base of every normal number

bobten2008的专栏 1182

POJ 1728 A flea on a chessboard

A flea on a chessboardTime Limit: 1000MS Memory Limit: 10000KTotal Submissions: 1509 Accepted: 491DescriptionAn infinite chessboard is obtained by extending a finit

bobten2008的专栏 1157

POJ 1906 Three Powers

Three powersTime Limit: 1000MS Memory Limit: 30000KTotal Submissions: 3299 Accepted: 1405DescriptionConsider the set of all non-negative integer powers of 3. S = {

bobten2008的专栏 1057
上一篇: POJ 1899 Farmer Bill's Problem
下一篇: POJ 1874 Trade on Verweggistan
bobten2008
博客等级 码龄18年 153粉丝 157原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值