HDU中大数实现的题目,持续更新(JAVA实现)
HDU1002:大数加法,PE了N次
import java.util.Scanner;
import java.math.*; public class Main
{
public static void main(String[] args)
{
Scanner cin = new Scanner(System.in);
int T;
T=cin.nextInt();
for(int z=1;z<=T;z++)
{
if(z!=1) System.out.println();
BigInteger a,b;
a=cin.nextBigInteger();
b=cin.nextBigInteger();
System.out.println("Case "+z+":");
System.out.println(a+" + "+b+" = "+a.add(b)); }
cin.close();
} }
HDU1042:N!大数乘法
import java.util.Scanner;
import java.math.*; import javax.naming.ldap.HasControls; public class Main{ public static void main(String[] args)
{
Scanner cin = new Scanner(System.in);
int t;
while(cin.hasNext())
{
BigInteger n=BigInteger.valueOf(1);
t=cin.nextInt();
for(int i=2;i<=t;i++)
{
n=n.multiply(BigInteger.valueOf(i));
}
System.out.println(n);
} } }
HDU1316:How Many Fibs?
import java.math.*;
import java.util.Scanner;
public class Main
{
public static void main(String[] args)
{
Scanner cin = new Scanner(System.in);
BigInteger []f=new BigInteger[1020];
f[0]=BigInteger.valueOf(1);
f[1]=BigInteger.valueOf(1);
f[2]=BigInteger.valueOf(2);
for(int i=3;i<1019;i++)
f[i]=f[i-1].add(f[i-2]);
BigInteger a,b;
int sum;
while(cin.hasNextBigInteger())
{
a=cin.nextBigInteger();
b=cin.nextBigInteger();
if(a.compareTo(BigInteger.ZERO)==0&&b.compareTo(BigInteger.ZERO)==0) break;
sum=0;
for(int i=1;i<=1015;i++)
{
if(f[i].compareTo(a)>=0&&f[i].compareTo(b)<=0)
{
sum++;
}
if(f[i].compareTo(b)>0) break;
}
System.out.println(sum);
}
cin.close();
} }
HDU1753: 大明 A+B 大数加法加一些函数
import java.math.*;
import java.util.Scanner;
public class Main
{
public static void main(String[] args)
{
Scanner cin = new Scanner(System.in);
BigDecimal a,b;
while(cin.hasNextBigDecimal())
{
a=cin.nextBigDecimal();
b=cin.nextBigDecimal();
System.out.println(a.add(b).stripTrailingZeros().toPlainString());
}
cin.close();
} }
HDU中大数实现的题目,持续更新(JAVA实现)的更多相关文章
- PHP 日常开发过程中的bug集合(持续更新中。。。)
PHP 日常开发过程中的bug集合(持续更新中...) 在日常php开发过程中,会遇到一些意想不到的bug,所以想着把这些bug记录下来,以免再犯! 1.字符串 '0.00'.'0.0'.'0' 是 ...
- UVA+POJ中大数实现的题目,持续更新(JAVA实现)
UVA10494:If We Were a Child Again 大数除法加取余 import java.util.Arrays; import java.util.Scanner; import ...
- Android中常用开发工具类—持续更新...
一.自定义ActionBar public class ActionBarTool { public static void setActionBarLayout(Activity act,Conte ...
- Android开发中常用的库总结(持续更新)
这篇文章用来收集Android开发中常用的库,都是实际使用过的.持续更新... 1.消息提示的小红点 微信,微博消息提示的小红点. 开源库地址:https://github.com/stefanjau ...
- SDUT中大数实现的题目,持续更新(JAVA实现)
SDUT2525:A-B (模板题) import java.util.Scanner; import java.math.*; public class Main { public static v ...
- 使用jenkins中遇到的问题汇总/持续更新
jenkins产生大量日志文件 question: [DNSQuestion@1446063419 type: TYPE_IGNORE index 0, class: CLASS_UNKNOWN in ...
- Vue开发中的常用技巧(持续更新)
1. 监听子组件的生命周期例如有父组件Parent和子组件Child,如果父组件监听到子组件挂载mounted就做一些逻辑处理,常规写法可能如下: // Parent.vue <Child @m ...
- Excel中遇到的一些问题——持续更新
Q1:excel2007表格里的数字在表格关闭后再打开经常会变成日期格式,怎么解决? A1: 1)打开Excel,选中任意单元格,单击鼠标右键,选择设置单元格格式2)在数字自定义类型中,找到类似[$- ...
- vue中的一些用法,持续更新中......
1.跳转用法 @1.在template模板中通常使用router-link to='url' @2.在js中 1.this.$router.push({path: ''/order/index''}) ...
随机推荐
- golang :连接数据库闲置断线的问题
golang在进行数据库操作,一般来说我们使用Open函数创建一个数据库(操作)句柄:func Open(driverName, dataSourceName string) (*DB, error) ...
- 2015 Multi-University Training Contest 5 1009 MZL's Border
MZL's Border Problem's Link: http://acm.hdu.edu.cn/showproblem.php?pid=5351 Mean: 给出一个类似斐波那契数列的字符串序列 ...
- 关于Nvelocity的主要语法和一些代码示例
context.Response.ContentType = "text/html"; VelocityEngine vltEngine = new VelocityEngine( ...
- ubuntu被delete的文件位置
在-/.local/share/Trash/files下边 可以通过 cd / find -name <filename> 找到盖文件的位置
- ie设置ActiveX控件不提示
ie设置自动允许activex: 对安全设置-受信任的站点区域-对未标记为可安全执行脚本的ActiveX控件初始化并执形脚本(启用)
- jdk 配置时时区设置
在eclipse中的 Default VM Arguments:添加 -Duser.timezone=Aisa/Shanghai
- 在WPF中弹出右键菜单时判断鼠标是否选中该项
和上篇在WPF的TreeView中实现右键选定一样,这仍然是一个右键菜单的问题: 这个需求是在一个实现剪贴板的功能的时候遇到的:在弹出右键菜单时,如果菜单弹出位置在ListViewItem中时,我 ...
- C++之异常处理
C++ Code 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849 ...
- hdu 2437(dfs)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2437 思路:只需用一个二维数组记录到达某点时路径长度mod k的最短路径长度,如果余数相同,就更新最小 ...
- Linux环境下Apache配置多个虚拟主机挂载多站点同时运行
博客地址: http://blog.csdn.net/ClydeKuo/article/details/69569474 这篇博客讲的很详细,很详细.