UVAOJ 575 基础题 斜二进制数 数论
发布日期:2022-03-30 20:19:25 浏览次数:36 分类:博客文章

本文共 1928 字,大约阅读时间需要 6 分钟。

http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=516

  Skew Binary 

When a number is expressed in decimal, the k-th digit represents a multiple of 10k. (Digits are numbered from right to left, where the least significant digit is number 0.) For example, 

 

 

 

When a number is expressed in binary, the k-th digit represents a multiple of 2k. For example, 

 

 

 

In skew binary, the k-th digit represents a multiple of 2k+1 - 1. The only possible digits are 0 and 1, except that the least-significant nonzero digit can be a 2. For example, 

 

 

 

The first 10 numbers in skew binary are 0, 1, 2, 10, 11, 12, 20, 100, 101, and 102. (Skew binary is useful in some applications because it is possible to add 1 with at most one carry. However, this has nothing to do with the current problem.)

 

Input 

The input file contains one or more lines, each of which contains an integer n. If n = 0 it signals the end of the input, and otherwise n is a nonnegative integer in skew binary.

 

Output 

For each number, output the decimal equivalent. The decimal value of n will be at most 231 - 1 = 2147483647.

 

Sample Input 

1012020000000000000000000000000000010100000000000000000000000000000011100111110000011100001011011020000

 

Sample Output 

44214748364632147483647471041110737

 

 


Miguel A. Revilla 
1998-03-10
/*************************************************************************    > File Name: 12345.cpp    > Author: acmicpcstar    > Mail: acmicpcstar@gmail.com    > Created Time: 2014年04月24日 星期四 11时46分18秒 ************************************************************************/#include
#include
#include
#include
#include
using namespace std;const double pi=atan(1.0)*4.0;int main(){string s;long long sum1,sum2,i;while(cin>>s){ if(s[0]=='0'&&s.length()==1) break;sum1=0;sum2=0;for(i=0;i

水题。。。用二进制化10进制。。。然后ans×2-各数位的和。。。

转载地址:https://www.cnblogs.com/acmicpcstar/p/3687185.html 如侵犯您的版权,请留言回复原文章的地址,我们会给您删除此文章,给您带来不便请您谅解!

上一篇:UVAOJ 10112 基础题 Myacm三角形 几何计算
下一篇:UVAOJ 375 基础题 内接圆和等腰三角形 几何计算

发表评论

最新留言

关注你微信了!
[***.104.42.241]2023年09月05日 19时37分02秒

关于作者

    喝酒易醉,品茶养心,人生如梦,品茶悟道,何以解忧?唯有杜康!
-- 愿君每日到此一游!

推荐文章

莱特币,全线矿机逼近关机价……比特币机皇S9也“很难” 2019-03-07
拨乱反正:区块链行业是如何被“炒币”妖魔化的? 2019-03-07
谷歌的“量子霸权”会冲击加密世界吗? 2019-03-07
江卓尔:比特币涨到十万美元需要多少资金? 2019-03-07
区块链应用的5大方向,哪些公司正在做? 2019-03-07
70% ETH持有者亏损,回本之路漫漫,你还会坚持看多吗? 2019-03-07
央行数字货币DCEP和支付宝、微信、比特币有什么不同? 2019-03-07
工行内测数字钱包背后: 中国引领货币潮流3000年 2019-03-07
BCH的“定时炸弹”?“BCH减半”对于其来说是一场灾难 2019-03-07
长期不能落地的区块链突破口在这里 2019-03-07
嘉楠往事:浮沉八载,如今剑指美股 2019-03-07
度宇宙、网易星球、爱得钻……这些大的区块链项目能否借机重生? 2019-03-07
过去两三年 互联网科技公司的掌舵人这样看区块链 2019-03-07
七家党媒一周发布65篇区块链报道:新华社发文最多 人民日报系最关注数据和产业... 2019-03-07
乌镇•政策风口下,区块链投资大佬告诉你,机会在哪里? 2019-03-07
支撑比特币价值的东西是什么? 2019-03-07
玲听2020跨年演讲:用100页PPT找到“区块链的确定感” 2019-03-07
调查:平均年薪超15万美金,美国区块链开发待遇这么高? 2019-03-07
平安壹账通陆一帆:通过牺牲区块链价值来达到隐私保护,无价值无意义 2019-03-07
展望2020 | Coinbase:加密货币这10年都经历了什么? 2019-03-07