大数阶乘

题目链接:http://acm.nyist.net/JudgeOnline/problem.php?pid=28

代码如下:

  1. import java.io.*;
  2. import java.math.BigInteger;
  3. import java.util.*;
  4. public class Main
  5. {
  6. public static void main(String args[])
  7. {
  8. Scanner cin = new Scanner(System.in);
  9. int n = cin.nextInt();
  10. BigInteger ans = BigInteger.ONE;
  11. for(int i = 1; i <= n; ++i)
  12. ans = ans.multiply(BigInteger.valueOf(i));
  13. System.out.println(ans);
  14. }
  15. }

棋盘覆盖

题目链接:http://acm.nyist.net/JudgeOnline/problem.php?pid=45

代码如下:

  1. import java.math.BigInteger;
  2. import java.util.*;
  3. import java.io.*;
  4. public class Main
  5. {
  6. public static void main(String args[])
  7. {
  8. Scanner in = new Scanner(System.in);
  9. int test = in.nextInt();
  10. while(test-- > 0)
  11. {
  12. int n;
  13. n = in.nextInt();
  14. BigInteger a = new BigInteger("4");
  15. for(int i = 1; i < n; ++i)
  16. a = a.multiply(BigInteger.valueOf(4));
  17. System.out.println(a.subtract(BigInteger.valueOf(1)).divide(BigInteger.valueOf(3)));
  18. }
  19. }
  20. }

比较大小

题目链接:http://acm.nyist.net/JudgeOnline/problem.php?pid=73

代码如下:

  1. import java.io.*;
  2. import java.math.BigInteger;
  3. import java.util.*;
  4. public class Main
  5. {
  6. public static void main(String args[])
  7. {
  8. Scanner cin = new Scanner(System.in);
  9. while(cin.hasNext())
  10. {
  11. BigInteger a = cin.nextBigInteger();
  12. BigInteger b = cin.nextBigInteger();
  13. if(a.equals(BigInteger.ZERO) && b.equals(BigInteger.ZERO))
  14. break;
  15. int flag = a.compareTo(b);
  16. if(flag == -1)
  17. System.out.println("a<b");
  18. else if(flag == 0)
  19. System.out.println("a==b");
  20. else
  21. System.out.println("a>b");
  22. }
  23. }
  24. }

大数加法

题目链接:http://acm.nyist.net/JudgeOnline/problem.php?pid=103

代码如下:

  1. import java.math.BigInteger;
  2. import java.util.*;
  3. import java.io.*;
  4. public class Main
  5. {
  6. public static void main(String args[])
  7. {
  8. Scanner in = new Scanner(System.in);
  9. int n = in.nextInt();
  10. for(int i = 1; i <= n; ++i)
  11. {
  12. BigInteger a = in.nextBigInteger();
  13. BigInteger b = in.nextBigInteger();
  14. BigInteger ans = a.add(b);
  15. System.out.println("Case " + i + ":");
  16. System.out.println(a + " + " + b + " = " +ans);
  17. }
  18. }
  19. }

递推求值

题目链接:http://acm.nyist.net/JudgeOnline/problem.php?pid=114

代码如下:

  1. import java.io.*;
  2. import java.math.BigInteger;
  3. import java.util.*;
  4. public class Main
  5. {
  6. public static void main(String args[])
  7. {
  8. Scanner cin = new Scanner(System.in);
  9. BigInteger a[] = new BigInteger[100];
  10. while(cin.hasNext())
  11. {
  12. for(int i = 0; i <= 2; ++i)
  13. a[i] = cin.nextBigInteger();
  14. for(int i = 3; i <= 99; ++i)
  15. a[i] = a[i - 1].add(a[i - 2]).add(a[i - 3]);
  16. System.out.println(a[99]);
  17. }
  18. }
  19. }

高精度幂

题目链接:http://acm.nyist.net/JudgeOnline/problem.php?pid=155

代码如下:

  1. import java.io.*;
  2. import java.math.BigDecimal;
  3. import java.util.*;
  4. public class Main
  5. {
  6. public static void main(String args[])
  7. {
  8. Scanner cin = new Scanner(System.in);
  9. while(cin.hasNext())
  10. {
  11. BigDecimal ans = cin.nextBigDecimal();
  12. int n = cin.nextInt();
  13. String res = ans.pow(n).stripTrailingZeros().toPlainString(); //整数去掉小数点和后面的0
  14. if(res.startsWith("0")) //去掉前导0
  15. {
  16. res = res.substring(1);
  17. }
  18. System.out.println(res);
  19. }
  20. }
  21. }

java题目练手的更多相关文章

  1. 10个相见恨晚的 Java 在线练手项目

    10个有意思的Java练手项目: 1.Java 开发简单的计算器 难度为一般,适合具有 Java 基础和 Swing 组件编程知识的用户学习 2.制作一个自己的 Java 编辑器 难度中等,适合 Ja ...

  2. java客房管理小项目,适合java小白练手的项目!

    java客房管理小项目 这个客房管理小项目,适合java初学者练手.功能虽然不多,但是内容很齐全! 喜欢这样文章的可以关注我,我会持续更新,你们的关注是我更新的动力!需要更多java学习资料的也可以私 ...

  3. JAVA初学练手项目,学生管理系统

    github地址:https://github.com/qscqesze/StudentManager 简单描述一下: UI层面用于接受用户的处理信息,然后移交给StudentDao去处理数据. 其中 ...

  4. JAVA反映练手

    import java.util.List; import java.util.ArrayList; import java.lang.reflect.Method; import java.lang ...

  5. JAVA泛型练手

    公司电脑不能安装JAVA环境,不爽啊. import java.util.List; import java.util.ArrayList; import java.lang.reflect.Meth ...

  6. JAVA大数类练手

    今天突然看到了OJ上的大数类题目,由于学习了一点大数类的知识.果断水了6道题......都是非常基础的.就当的练手的吧. 学到的只是一些大数类的基本操作.以后多做点这样的题,争取熟练运用水大数题... ...

  7. 20个Java练手项目,献给嗜学如狂的人

    给大家推荐一条由浅入深的JAVA学习路径,首先完成 Java基础.JDK.JDBC.正则表达式等基础实验,然后进阶到 J2SE 和 SSH 框架学习.最后再通过有趣的练手项目进行巩固. JAVA基础 ...

  8. Java学习路径及练手项目合集

    Java 在编程语言排行榜中一直位列前排,可知 Java 语言的受欢迎程度了. 实验楼上的[Java 学习路径]中将首先完成 Java基础.JDK.JDBC.正则表达式等基础实验,然后进阶到 J2SE ...

  9. 去哪找Java练手项目?

    经常有读者在微信上问我: 在学编程的过程中,看了不少书.视频课程,但是看完.听完之后感觉还是不会编程,想找一些项目来练手,但是不知道去哪儿找? 类似的问题,有不少读者问,估计是大部分人的困惑. 练手项 ...

随机推荐

  1. iTween插件使用

    itween插件 itween是一个动画库,作者创建它的目的就是最小的投入实现最大的产出.用它可以轻松实现各种动画,晃动,旋转,移动.褪色.上色.控制音频等. iTween原理: itween的核心是 ...

  2. Linux CentOS 7下Memcached 安装与配置

    前言 本篇文章记录一下Linux CentOS 7中关于Memcached的安装与配置. 安装 安装memcached之前首先需要安装libevent,我这里用的版本是: •libevent-2.0. ...

  3. Django之博客系统:自定义模板标签

    Django提供了很多内置的模板标签比如{% if %}或者{% block %}Django也允许你创建自己的模板标签(template tags)来执行自定义的动作.当你需要在你的模板中添加功能而 ...

  4. 数据结构13: 括号匹配算法及C语言实现

    在编写代码的时候,经常会用到两种括号:圆括号 “()” 和大括号 “{}” .不管使用哪种括号,程序编译没有问题的其中一个重要因素就是所使用的括号是否能够匹配上. 在编写程序时,括号可以嵌套,即: “ ...

  5. Gym - 101845F 最大流

    The UN finals are here!, the coaches/ex-coaches team is creating a new exciting contest to select wh ...

  6. 11.Find All Numbers Disappeared in an Array(找出数组中缺失的数)

    Level:   Easy 题目描述: Given an array of integers where 1 ≤ a[i] ≤ n (n = size of array), some elements ...

  7. error : Could not load UI satellite dll 'TrackerUI.dll'. Make sure it exists in an LCID subdirectory of 'C:\Program Files (x86)\MSBuild\12.0\bin\'.

    原因  VS2013 + QT环境部署好后, 又安装了VS2015\ 解决方案:  在另一台电脑里重装VS2013, 并将  C:\Program Files (x86)\MSBuild\12.0\B ...

  8. java 中 静态泛型方法书写

    public class SpringBean { /** * */ public static <T> T getBean(Class<T> clazz,String nam ...

  9. 2015苏州大学ACM-ICPC集训队选拔赛(2)1002

    草爷要的雷 Problem Description 扫雷一直是风靡实验室的重要娱乐游戏,在赛前赛后.刷题疲惫的时候,扫一局雷经常可以让队员们感受到身心的振奋,毕竟,劳逸结合刷题,防猝死才是硬道理.但是 ...

  10. UBoot添加命令的方法

    1. 具体实现步骤 ① 在./common文件夹下新建cmd_led.c,并在此文件中添加如下内容 #include <common.h> #include <command.h&g ...