bzoj1000 A+B Problem

Scanner sc=new Scanner(new BufferedInputStream(System.in)); 声明读入器

nextInt 读入整数

System.out.println 带换行输出

import java.util.*;
import java.io.*; public class Main{
public static void main(String[] argc){
Scanner sc = new Scanner (new BufferedInputStream(System.in));
int a=sc.nextInt(),b=sc.nextInt();
System.out.println(a+b);
sc.close();
}
}

poj1503 Integer Inquiry

BigInteger.ZERO 大整数常量零

equals 相等

add 加

import java.util.*;
import java.io.*;
import java.math.*; public class Main{
public static void main(String[] argc){
Scanner sc = new Scanner (new BufferedInputStream(System.in));
BigInteger sum=BigInteger.ZERO;
while(true){
BigInteger x=sc.nextBigInteger();
if(x.equals(BigInteger.ZERO)){
break;
}
sum=sum.add(x);
}
System.out.println(sum);
sc.close();
}
}

poj1001 求高精度幂

stripTrailingZeros 清除不影响大小的零

toPlainString 以朴素的方式(而非科学计数法或工程计数法)将BigDecimal转换成String

hasNext 判断是否读入完成

next 读入字符串,直到空格为止

nextLine 读入一整行字符串

public String substring(int beginIndex) 返回该字符串从beginIndex开始到结尾的子字符串;

public String substring(int beginIndex,int endIndex) 返回该字符串从beginIndex开始到endsIndex结尾的子字符串

import java.util.*;
import java.io.*;
import java.math.*; public class Main {
public static void main(String[] argc){
Scanner sc=new Scanner(new BufferedInputStream(System.in));
while(sc.hasNext()){
String s=sc.next();
int n=sc.nextInt();
BigDecimal x=new BigDecimal(s);
s=x.pow(n).stripTrailingZeros().toPlainString();
if(s.charAt(0)=='0'){
s=s.substring(1);
}
System.out.println(s);
}
sc.close();
}
}

bzoj1876 [SDOI2009]SuperGCD

gcd 求两个大整数的gcd

import java.util.*;
import java.io.*;
import java.math.*; public class Main {
public static void main(String[] argc){
Scanner sc=new Scanner(new BufferedInputStream(System.in));
BigInteger a=sc.nextBigInteger();
BigInteger b=sc.nextBigInteger();
System.out.println(a.gcd(b));
sc.close();
}
}

最新文章

  1. C# socket UDPの异步链接
  2. maven2-snapshot快照库和release发布库的应用
  3. HOJ 2678 Stars
  4. 专题实验 PGA
  5. DISP_FUNCTION用法
  6. MYSQL日常操作命令再熟悉
  7. GUI编程笔记(java)07:GUI把文本框的值移到文本域案例
  8. Solr4.8.0源码分析(24)之SolrCloud的Recovery策略(五)
  9. 批处理Bat实现整合定时关机或取消定时关机
  10. BCDBOOT命令参数介绍
  11. Hadoop 新生报道(二) hadoop2.6.0 集群系统版本安装和启动配置
  12. amazeui表单form异步提交方法
  13. 我知道的nginx配置
  14. Windows 下配置 Apache 支持 https
  15. Spring Cloud 各组件调优参数
  16. Gitkraken的使用
  17. 几个简单易懂的排序算法php
  18. 【C/C++】C/C++中Static的作用详述
  19. maven学习(3)-Maven 核心技术
  20. 开始第一个Android应用程序

热门文章

  1. 设计一个JavaScript框架需要编写哪些模块
  2. Spring AOP execution表达式
  3. Dilworth定理证明
  4. ionic3自定义图标
  5. finally return 执行顺序问题
  6. Xcode5根控制器使用xib展示的步骤
  7. setInterval的使用和停用
  8. alt+ F8 设置无效(转)
  9. Linux服务器中毒事件(libudev.so)
  10. csrf_execmp