package array;
import java.util.Scanner;
public class youxi1 {
public static void main(String[] args) {
Scanner console = new Scanner(System.in);
System.out.println("游戏开始");
int sum=0;//记总分变量sum
for(int i=0;i<10;i++){
......................
阅读全部
|
吉羊
贴于 2019年1月6日 14:53
hide
bbsi
import java.util.*;class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); while (sc.hasNext()) { int N = sc.nextInt(); MultiValueMap<String, String> stringMultiValueMap = new LinkedMultiValueMap<>(); while (N-- > 0) { String id = sc.next(); String time = sc.next(); stringMultiValueMap.add(id, time); } Set<String> keySet = stringMultiValueMap.keySet(); for (String key : keySet) { List<String> values = stringMultiValueMap.getValues(key); if (values.size() < 6) continue; ArrayList<Integer> total_times = new ArrayList<>(); for (String value : values) { int h = Integer.parseInt(value.substring(0, 2)); int d = Integer.parseInt(value.substring(3, 5)); int s = Integer.parseInt(value.substring(6, 8)); int total_time = h * 3600 + d * 60 + s; total_times.add(total_time); } Collections.sort(total_times); if (check(total_times)) System.out.println(key); } } } private static boolean check(ArrayList<Integer> list) { for (int i = 0; i <= list.size() - 6; i++) { for (int j = i + 1; j < i + 6; j++) { if (Math.abs(list.get(i) - list.get(j)) >= 3600) return false; } } return true; }}interface MultiValueMap<K, V> { void add(K key, V value); void add(K key, List<V> values); void set(K key, V value); void set(K key, List<V> values); void set(Map<K, List<V>> values); List<V> remove(K key); void clear(); Set<K> keySet(); List<V> values(); V getValue(K key, int index); List<V> getValues(K key); int size(); boolean isEmpty(); boolean containsKey(K key);}class LinkedMultiValueMap<K, V> implements MultiValueMap<K, V> { protected Map<K, List<V>> mSource = new LinkedHashMap<K, List<V>>(); public LinkedMultiValueMap() { } @Override public void add(K key, V value) { if (key != null) { if (!mSource.containsKey(key)) mSource.put(key, new ArrayList<V>(2)); mSource.get(key).add(value); } } @Override public void add(K key, List<V> values) { for (V value : values) { add(key, value); } } @Override public void set(K key, V value) { mSource.remove(key); add(key, value); } @Override public void set(K key, List<V> values) { mSource.remove(key); add(key, values); } @Override public void set(Map<K, List<V>> map) { mSource.clear(); mSource.putAll(map); } @Override public List<V> remove(K key) { return mSource.remove(key); } @Override public void clear() { mSource.clear(); } @Override public Set<K> keySet() { return mSource.keySet(); } @Override public List<V> values() { List<V> allValues = new ArrayList<V>(); Set<K> keySet = mSource.keySet(); for (K key : keySet) { allValues.addAll(mSource.get(key)); } return allValues; } @Override public List<V> getValues(K key) { return mSource.get(key); } @Override public V getValue(K key, int in
阅读全部
|
java小白兔
贴于 2018年11月7日 16:57
hide
bbsi
import java.util.*;class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); while (sc.hasNext()) { int N = sc.nextInt(); MultiValueMap<String, String> stringMultiValueMap = new LinkedMultiValueMap<>(); while (N-- > 0) { String id = sc.next(); String time = sc.next(); stringMultiValueMap.add(id, time); } Set<String> keySet = stringMultiValueMap.keySet(); for (String key : keySet) { List<String> values = stringMultiValueMap.getValues(key); if (values.size() < 6) continue; ArrayList<Integer> total_times = new ArrayList<>(); for (String value : values) { int h = Integer.parseInt(value.substring(0, 2)); int d = Integer.parseInt(value.substring(3, 5)); int s = Integer.parseInt(value.substring(6, 8)); int total_time = h * 3600 + d * 60 + s; total_times.add(total_time); } Collections.sort(total_times); if (check(total_times)) System.out.println(key); } } } private static boolean check(ArrayList<Integer> list) { for (int i = 0; i <= list.size() - 6; i++) { for (int j = i + 1; j < i + 6; j++) { if (Math.abs(list.get(i) - list.get(j)) >= 3600) return false; } } return true; }}interface MultiValueMap<K, V> { void add(K key, V value); void add(K key, List<V> values); void set(K key, V value); void set(K key, List<V> values); void set(Map<K, List<V>> values); List<V> remove(K key); void clear(); Set<K> keySet(); List<V> values(); V getValue(K key, int index); List<V> getValues(K key); int size(); boolean isEmpty(); boolean containsKey(K key);}class LinkedMultiValueMap<K, V> implements MultiValueMap<K, V> { protected Map<K, List<V>> mSource = new LinkedHashMap<K, List<V>>(); public LinkedMultiValueMap() { } @Override public void add(K key, V value) { if (key != null) { if (!mSource.containsKey(key)) mSource.put(key, new ArrayList<V>(2)); mSource.get(key).add(value); } } @Override public void add(K key, List<V> values) { for (V value : values) { add(key, value); } } @Override public void set(K key, V value) { mSource.remove(key); add(key, value); } @Override public void set(K key, List<V> values) { mSource.remove(key); add(key, values); } @Override public void set(Map<K, List<V>> map) { mSource.clear(); mSource.putAll(map); } @Override public List<V> remove(K key) { return mSource.remove(key); } @Override public void clear() { mSource.clear(); } @Override public Set<K> keySet() { return mSource.keySet(); } @Override public List<V> values() { List<V> allValues = new ArrayList<V>(); Set<K> keySet = mSource.keySet(); for (K key : keySet) { allValues.addAll(mSource.get(key)); } return allValues; } @Override public List<V> getValues(K key) { return mSource.get(key); } @Override public V getValue(K key, int in
阅读全部
|
java小白兔
贴于 2018年11月7日 16:57
hide
bbsi
public class Lei {
String name;
}
class Lei1{
public static void main(String[] args) {
Lei S1=new Lei();
System.out.println(S1.name);
}
} 本来是应该输出空值Null的,但是我的就是不能老报错,求大神指导
阅读全部
|
陈无
贴于 2018年10月25日 22:55
hide
bbsi
public class Bccn{
public static void main(String[] args){
int R = 10;
double PI = 3.14;
double Area = (int)(PI*R*R);
double Perimeter = (int)(2*PI*R);
System.out.println(Area);
System.out.println(Perimeter);
}
}
阅读全部
|
muncky
贴于 2018年8月26日 15:15
hide
bbsi
HTTP Status 500 -
type Exception report
message
description The server encountered an internal error that prevented it from fulfilling this request.
exception
java.lang.NullPointerException
cn.zzw.mess.servlet.UserServlet.doPost(UserServlet.java:82)
javax.servlet.http.HttpServlet.service(HttpServlet.java:650)
......................
阅读全部
|
hyx5966
贴于 2018年7月24日 17:28
hide
bbsi
HTTP Status 500 -
type Exception report
message
description The server encountered an internal error that prevented it from fulfilling this request.
exception
java.lang.NullPointerException
cn.zzw.mess.servlet.UserServlet.doPost(UserServlet.java:82)
javax.servlet.http.HttpServlet.service(HttpServlet.java:650)
......................
阅读全部
|
hyx5966
贴于 2018年7月24日 17:28
hide
bbsi
public class ForDemo{
public class static coid main(String args []){
int sum = 0;
for (int x = 1; x <= 100; x++) {
sum += x;
}
System.out.println("1-->100累加:” + sum);
}
}
阅读全部
|
小城故事多
贴于 2018年4月22日 15:41
hide
bbsi
public class 新人{
public static void main(string args[]) {
int x = 1;
int sum = 0;
While (x <= 100) {
sum += x;
x++;
}
System.out.println("1-->100累加” + sum);
}
}
阅读全部
|
小城故事多
贴于 2018年4月22日 15:33
hide
bbsi
public class 新人{
public static void main(string args[]) {
int x = 1;
int sum = 0;
While (x <= 100) {
sum += x;
x++;
}
System.out.println("1-->100累加” + sum);
}
}
阅读全部
|
小城故事多
贴于 2018年4月22日 15:32
hide
bbsi