虽然题目那么长其实就是把8进制的浮点数转换成10进制,为了练习Java Biginteger 类 我这里用的是Java,也可以用数组模拟. import java.math.BigDecimal; import java.math.RoundingMode; import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner cin = new Scanner(System.…
http://poj.org/problem?id=1220 高精度任意进制转换 代码是从discuss里找到的,据说是maigo神牛写的. 超精简!! 我自己第一写的时候,还把n进制先转成10进制,然后再从10进制转为m进制... 悲催的是写了好长滴,还没调对啊!!! Code: #include <stdio.h> #include <string.h> const int maxn = 1000; int t[maxn], A[maxn]; char str1[maxn],…
题目链接 题意 : 将一个10进制整数转化为-2进制的数. 思路 :如果你将-2进制下的123转化为十进制是1*(-2)^2+2*(-2)^1+3*(-2)^0.所以十进制转化为-2进制就是一个逆过程.找到最小的非负整数x使得当前数减x能被2整除,这个x将作为新的最高位写到结果中,然后当前数减去x再除以-2,貌似在这里不能严格的说是余数,因为负数的余数不太准确. //POJ 3191 #include <stdio.h> #include <string.h> #include &…
题目连接:1220 NUMBER BASE CONVERSION 题目大意:给出两个进制oldBase 和newBase, 以及以oldBase进制存在的数.要求将这个oldBase进制的数转换成newBase进制的数. 解题思路:短除法,只不过时直接利用了高精度的除法运算, 并且将以前默认的*10换成的*oldBase. #include <stdio.h> #include <string.h> const int N = 1005; int newBase, oldBase,…
今天周末学习的不多,只学习了一些二进制转十进制,八进制.十六进制,以及数据单位 二进制转十进制 我们都知道十进制转二进制就是除以2取余的方法.那二进制转到十进制又如何处理呢,今天我来学习以下 我们看看二进制数1010转换为十进制,方法如图所示 八进制 方法为:3位二进制数按权展开相加得到1位八进制数.(注意事项,3位二进制转成八进制是从右到左开始转换,不足时补0). 二进制数 10010110 转八进制 结果如下图 十六进制 十六进制也是开发中常用到的 首先看看二进制和十六进制的一个关系,如下图…
POJ1131   由于本题只有小数部分(整数部分均为0),故在进制转换的之后只能自己手写转换方法了.   8进制转换10进制的方法为,以0.75为例,应是7*8^-1 + 5*8^-2.所以呢,可以直接定位到小数点后一位,采用此方法进行计算. import java.util.*; import java.math.*; public class Main { public static void main(String []args) { Scanner cin = new Scanner(…
今天撸3708  一直奇怪的re 就先放下了,写这个题的过程中学习了一个高精度进制转换,用这个模板写了1220 记录一下: #include <iostream> #include <stdio.h> #include<string.h> #include<algorithm> #include<string> #include<ctype.h> using namespace std; #define MAXN 10000 ]; ]…
/* 高精度进制转换 把oldBase 进制的数转化为newBase 进制的数输出. 调用方法,输入str, oldBase newBase. change(); solve(); output(); 也可以修改output(),使符合要求,或者存入另外一个字符数组,备用 */ #include<stdio.h> #include<string.h> #defien MAXSIZE char str[MAXSIZE];//输入字符串 int start[MAXSIZE],ans[M…
常规短除法原理 高精度进制转换是对于特别大的数字来说的,当数字特别大时,难以进行除法和取余的操作,此时通过字符串模拟的办法可以解决. #include <iostream> #include <cstdio> #include <cstring> #include <algorithm> using namespace std; typedef long long ll; const int maxn = 2000 + 5; int niput[maxn];…
The Embarrassed Cryptographer Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 15767   Accepted: 4337 Description The young and very promising cryptographer Odd Even has implemented the security module of a large system with thousands of…