java
文章平均质量分 53
「已注销」
奋斗中的mywaya
展开
-
一个hasnextdouble()的小问题
import java.util.Scanner;public class ScanTest { public static void main(String[] args) { System.out.println("请输入数字:"); Scanner scan = new Scanner(System.in); double sum = 0; int m = 0;...原创 2020-02-11 20:49:19 · 1020 阅读 · 1 评论 -
Composition
题目1 : Composition时间限制:10000ms单点时限:1000ms内存限制:256MB描述Alice writes an English composition with a length of N characters. However, her teacher requires that M illegal pairs of characters cannot...原创 2019-01-05 13:31:52 · 228 阅读 · 0 评论 -
Boarding Passes
题目1 : Boarding Passes时间限制:10000ms单点时限:1000ms内存限制:256MB描述Long long ago you took a crazy trip around the world. You can not remember which cities did you start and finish the trip. Luckily yo...原创 2019-01-01 11:51:31 · 404 阅读 · 1 评论 -
Total Hamming Distance
题目1 : Total Hamming Distance时间限制:10000ms单点时限:1000ms内存限制:256MB描述The Hamming Distance between two integers is the number of different digits between their binary representation. For example th...原创 2019-01-01 12:35:11 · 109 阅读 · 0 评论 -
Shortening Sequence
题目1 : Shortening Sequence时间限制:10000ms单点时限:1000ms内存限制:256MB描述There is an integer array A1, A2 ...AN. Each round you may choose two adjacent integers. If their sum is an odd number, the two ad...原创 2019-01-06 15:57:15 · 124 阅读 · 0 评论 -
Composition
题目1 : Composition时间限制:10000ms单点时限:1000ms内存限制:256MB描述Alice writes an English composition with a length of N characters. However, her teacher requires that M illegal pairs of characters cannot...原创 2019-01-06 16:39:00 · 356 阅读 · 0 评论 -
Powers of Two
第209周题目1 : Powers of Two时间限制:10000ms单点时限:1000ms内存限制:256MB描述Given a positive integer N, it is possible to represent N as the sum of several positive or negative powers of 2 (± 2k for some k...原创 2019-01-02 22:14:49 · 265 阅读 · 0 评论 -
Guess Number with Lower or Higher Hints
题目1 : Guess Number with Lower or Higher Hints时间限制:10000ms单点时限:1000ms内存限制:256MB描述There is a game about guessing number between 1 and N. This game is played by two people A and B. When A guess...原创 2019-01-03 11:19:21 · 88 阅读 · 0 评论 -
奖券兑换
题目1 : 奖券兑换时间限制:20000ms单点时限:1000ms内存限制:256MB描述小Hi在游乐园中获得了M张奖券,这些奖券可以用来兑换奖品。可供兑换的奖品一共有N件。第i件奖品需要Wi张奖券才能兑换到,其价值是Pi。 小Hi使用不超过M张奖券所能兑换到的最大奖品总价值是多少?输入第一行两个整数N,M。 接下来N行,每行两个整数Wi,Pi。 ...原创 2019-01-12 20:05:58 · 371 阅读 · 0 评论 -
Five in a Row
题目1 : Five in a Row时间限制:10000ms单点时限:1000ms内存限制:256MB描述Five in a Row is a game played on a 15x15 go board. Black and White take turns to place a stone of their color in an empty spot. The win...原创 2019-01-05 12:17:53 · 321 阅读 · 0 评论 -
MS Recognition
题目1 : MS Recognition时间限制:30000ms单点时限:3000ms内存限制:256MB描述Given an image containing only two kinds of capital letters, 'M' and 'S', can you tell how many of each letter are there in the image? ...原创 2019-01-05 12:10:31 · 156 阅读 · 0 评论 -
Smallest Rectangle
题目1 : Smallest Rectangle时间限制:10000ms单点时限:1000ms内存限制:256MB描述You are given N 2D points P1, P2, ... PN. If there is a rectangle satisfying that its 4 vertices are in the given point set and its...原创 2018-12-31 12:18:23 · 262 阅读 · 0 评论 -
Java Scanner 类详解(附例子)学习
在笔试编程过程中,关于数据的读取如果迷迷糊糊,那后来的编程即使想法很对,实现很好,也是徒劳,于是在这里认真总结了Java Scanner 类的使用通过 Scanner 类来获取用户的输入,下面是创建 Scanner 对象的基本语法:Scanner s = new Scanner(System.in); // 从键盘接收数据接下来我们演示一个最简单的数据输入,并通过 Scanner ...转载 2018-10-26 08:54:22 · 327 阅读 · 3 评论 -
java的遍历方法
解析:三种方法都是用来遍历ArrayList集合,第三种方法是采用迭代器的方法,该方法可以不用担心在遍历的过程中会超出集合的长度。遍历 Map实例...原创 2018-10-26 09:47:43 · 8245 阅读 · 0 评论 -
Spring afterPropertiesSet方法
今天写mysql数据库主从读写分离时,需要根据datasource的配置信息,获取到从库的数量,来实现从库轮询策略访问,在看spring中的AbstractRoutingDataSource源码时,看到afterPropertiesSet方法,然后在网上看到了这篇博客,写的很详细。-------------------------------------------------------...转载 2018-11-04 10:32:39 · 6022 阅读 · 0 评论 -
删除ArrayList元素的4种正确方法
删除ArrayList元素的4种正确方法1.倒序删倒序删不会出现像正序删那样因为删完元素后剩余的元素索引发生改变而遗漏元素并且最终会报 java.lang.IndexOutOfBoundsException 异常的情况。public static void remove(List<String> list, String target) { for(int i...转载 2018-11-22 22:14:05 · 19986 阅读 · 0 评论 -
hiho232周 拆字游戏
时间限制:10000ms单点时限:1000ms内存限制:256MB描述小Kui喜欢把别人的名字拆开来,比如“螺”就可以拆成“虫田糸”,小Kui的语文学的不是很好,于是她决定使用编程的方式来解决这个问题。给出一个01矩阵,1占据的部分即为需要拆的字,如果两个1分享一条边,那么它们连通。连通具有传递性,即如果a、b连通,b、c连通,则a、c连通。连通的一系列1被看做可以拆出的一...原创 2018-12-20 17:15:24 · 226 阅读 · 0 评论 -
Java中ArrayList的排序两种方法以及遍历的代码
方法一:在类的定义中实现Comparable接口中的compareTo()方法,然后调用Collections.sort()进行排序:import java.util.Scanner; import java.util.ArrayList; import java.util.Collections; import java.util.Iterator; class Student ...转载 2018-12-20 20:31:34 · 258 阅读 · 0 评论 -
JAVA中HashMap遍历以及排序代码
HashMap遍历import java.util.HashMap;import java.util.Map;import java.util.Scanner;public class Main { public static void main(String[] args) { HashMap<String,String> map=new...转载 2018-12-20 20:33:19 · 564 阅读 · 0 评论 -
Push Button I
题目1 : Push Button I时间限制:5000ms单点时限:1000ms内存限制:256MB描述There are N buttons on the console. Each button needs to be pushed exactly once. Each time you may push several buttons simultaneously....原创 2018-12-29 15:22:04 · 343 阅读 · 0 评论 -
闰秒
题目1 : 闰秒时间限制:10000ms单点时限:1000ms内存限制:256MB描述计算机系统中使用的UTC时间基于原子钟,这种计时方式同“地球自转一周是24小时”的计时方式有微小的偏差。为了弥补这种偏差,我们偶尔需要增加一个“闰秒”。 最近的一次闰秒增加发生在UTC时间2016年的最后一天。我们在2016年12月31日23时59分59秒和2017年1月1日0时0分0秒...原创 2018-12-31 10:45:05 · 4347 阅读 · 0 评论 -
javac不是内部命令
我的jdk'和jre都安装在java_jdk这个文件夹下,如上图所示。在环境变量中的path和classpath的参数配置如下:变量名:JAVA_HOME 变量值:F:\java_jdk\jdk1.8变量名:Path 变量值:.;%JAVA_HOME%\bin;%JAVA_HOME%\jre\bin;变量名:classpath ...原创 2018-08-10 08:36:51 · 517 阅读 · 2 评论