poj 2305(指定进制,大数取模)
来源:互联网 发布:双11淘宝报名入口 编辑:程序博客网 时间:2024/05/29 14:17
题意:输入一个进制b,在输入两个基于b进制的大整数 x,y ,求x%y的b进制结果。
http://162.105.81.212/JudgeOnline/problem?id=2305
函数:
String st = Integer.toString(num, base); // 把num当做10进制的数转成base进制的st(base <= 35).
int num = Integer.parseInt(st, base); // 把st当做base进制,转成10进制的int(parseInt有两个参数,第一个为要转的字符串,第二个为说明是什么进制).
BigInter m = new BigInteger(st, base); // st是字符串,base是st的进制.
//Added by abilitytao
1.如果要将一个大数以2进制形式读入 可以使用cin.nextBigInteger(2);
当然也可以使用其他进制方式读入;
2.如果要将一个大数转换成其他进制形式的字符串 使用cin.toString(2);//将它转换成2进制表示的字符串
import java.math.*; import java.util.*;import java.math.BigInteger;public class Main{ public static void main (String[] args)throws Exception { Scanner in=new Scanner(System.in); int b; BigInteger x,y; while(in.hasNextInt()) { b=in.nextInt(); if(b==0) break; x=in.nextBigInteger(b); y=in.nextBigInteger(b); x=x.mod(y); System.out.println(x.toString(b)); } } }
- poj 2305(指定进制,大数取模)
- POJ 2635 N进制大数与小数取模
- poj(2635 大数取模)
- POJ 2536 大数取模运算
- 算法 大数计算:加减乘除,模,阶乘,进制转换(大数除法取余)
- hdu5832(大数取模)
- poj The Embarrassed Cryptographer(大数取模)(同余模定理)
- POJ 2635 The Embarrassed Cryptographer 大数取模
- 大数运算(加减乘除,取模,乘方)
- hdu(1212)大数取模
- 大数(高精度)加减乘除取模运算
- UVA128 - Software CRC(大数取模)
- np问题(大数阶乘取模)
- java大数取模(一)
- 大数取模运算
- 大数取模
- 大数取模
- 大数取模 poj2635
- Gallery2修改记录
- 数据结构教材学生满意度为96%,感到非常欣慰(现在提供免费课件下载地址)
- GDB linux单步调试
- 二叉搜索树 c 语言实现
- JAVA之Math类的数学运算应用详解
- poj 2305(指定进制,大数取模)
- tomcat7 源码学习(源码导入eclipse)
- FCL应用技巧之------DirectoryInfo.GetFiles()搜索模式存在的问题
- VS2008+OpenCV配置成功(转)
- Linux CentOs6.5_x64静默安装Oracle10g
- java国际化
- 数据库性能优化之SQL语句优化1
- C++ char* char a[] string叛空
- c语言所有的errno枚举值含义