mirror of
https://gitee.com/pronting/DataStructureAndAlgorithm.git
synced 2024-12-22 20:54:22 +08:00
玛蹄杯刷题
This commit is contained in:
parent
e0404d7be7
commit
b282250934
38
java/priv/pront/code/mati/province/MC0102_房间打扫.java
Normal file
38
java/priv/pront/code/mati/province/MC0102_房间打扫.java
Normal file
@ -0,0 +1,38 @@
|
||||
package priv.pront.code.mati.province;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Scanner;
|
||||
|
||||
/**
|
||||
* @Description:
|
||||
* @Author: pront
|
||||
* @Time:2023-11-11 14:12
|
||||
*/
|
||||
public class MC0102_房间打扫 {
|
||||
|
||||
static int n;
|
||||
static Map<String, Integer> map = new HashMap<>();
|
||||
static int max = 1;
|
||||
public static void main(String[] args) {
|
||||
Scanner scanner = new Scanner(System.in);
|
||||
n = scanner.nextInt();
|
||||
for (int i = 0; i < n; i++) {
|
||||
String s = scanner.next();
|
||||
if (map.containsKey(s)) {
|
||||
for (Map.Entry<String, Integer> cur : map.entrySet()) {
|
||||
String key = cur.getKey();
|
||||
if(key.equals(s)) map.put(key, map.get(key) + 1);
|
||||
}
|
||||
}else{
|
||||
map.put(s, 1);
|
||||
}
|
||||
}
|
||||
for (Map.Entry<String, Integer> cur : map.entrySet()) {
|
||||
Integer value = cur.getValue();
|
||||
max = Math.max(max, value);
|
||||
}
|
||||
|
||||
System.out.println(max);
|
||||
}
|
||||
}
|
32
java/priv/pront/code/mati/province/MC0108_白给.java
Normal file
32
java/priv/pront/code/mati/province/MC0108_白给.java
Normal file
@ -0,0 +1,32 @@
|
||||
package priv.pront.code.mati.province;
|
||||
|
||||
import java.util.Scanner;
|
||||
|
||||
/**
|
||||
* @Description:
|
||||
* @Author: pront
|
||||
* @Time:2023-11-11 13:55
|
||||
*/
|
||||
public class MC0108_白给 {
|
||||
|
||||
static int x, y, t;
|
||||
public static void main(String[] args) {
|
||||
Scanner scanner = new Scanner(System.in);
|
||||
x = scanner.nextInt();
|
||||
y = scanner.nextInt();
|
||||
t = scanner.nextInt();
|
||||
while (t-- > 0) {
|
||||
if(x >= y){
|
||||
y += x / 2;
|
||||
x -= x / 2;
|
||||
}else{
|
||||
x += y / 2;
|
||||
y -= y / 2;
|
||||
}
|
||||
}
|
||||
System.out.println(x + " " + y);
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
36
java/priv/pront/code/mati/province/MC0110_曼哈顿距离矩阵.java
Normal file
36
java/priv/pront/code/mati/province/MC0110_曼哈顿距离矩阵.java
Normal file
@ -0,0 +1,36 @@
|
||||
package priv.pront.code.mati.province;
|
||||
|
||||
import java.util.Scanner;
|
||||
|
||||
/**
|
||||
* @Description:
|
||||
* @Author: pront
|
||||
* @Time:2023-11-11 15:09
|
||||
*/
|
||||
public class MC0110_曼哈顿距离矩阵 {
|
||||
|
||||
static int x, y;
|
||||
public static void main(String[] args) {
|
||||
Scanner scanner = new Scanner(System.in);
|
||||
x = scanner.nextInt();
|
||||
y = scanner.nextInt();
|
||||
int n = Math.abs(x) + Math.abs(y);
|
||||
int start = 0;
|
||||
for (int i = 2; i < n; i++) {
|
||||
start += i * 4;
|
||||
}
|
||||
if (n > 0) start += 4;
|
||||
|
||||
if (y >= 0 && x > 0) {
|
||||
start += x;
|
||||
} else if (y < 0 && x >= 0) {
|
||||
start += n - y;
|
||||
} else if (y <= 0 && x < 0) {
|
||||
start += 2 * n - x;
|
||||
} else if (y > 0 && x <= 0) {
|
||||
start += 3 * n + y;
|
||||
}
|
||||
System.out.println(start);
|
||||
|
||||
}
|
||||
}
|
29
java/priv/pront/code/mati/province/MC0112_白日梦I.java
Normal file
29
java/priv/pront/code/mati/province/MC0112_白日梦I.java
Normal file
@ -0,0 +1,29 @@
|
||||
package priv.pront.code.mati.province;
|
||||
|
||||
import java.util.Scanner;
|
||||
|
||||
/**
|
||||
* @Description:
|
||||
* @Author: pront
|
||||
* @Time:2023-11-11 14:30
|
||||
*/
|
||||
// FIXME 错一个点
|
||||
public class MC0112_白日梦I {
|
||||
|
||||
static int n;
|
||||
static int[] a;
|
||||
public static void main(String[] args) {
|
||||
Scanner scanner = new Scanner(System.in);
|
||||
n = scanner.nextInt();
|
||||
a = new int[n];
|
||||
int max = Integer.MIN_VALUE;
|
||||
double ans = 1.00;
|
||||
a[0] = scanner.nextInt();
|
||||
for (int i = 1; i < n; i++) {
|
||||
max = Math.max(max, a[i - 1]);
|
||||
a[i] = scanner.nextInt();
|
||||
ans = Math.max(ans, (double) max / a[i]);
|
||||
}
|
||||
System.out.printf("%.2f", 10 * ans);
|
||||
}
|
||||
}
|
92
java/priv/pront/code/mati/province/MC0203_小玛哥的艰难抉择.java
Normal file
92
java/priv/pront/code/mati/province/MC0203_小玛哥的艰难抉择.java
Normal file
@ -0,0 +1,92 @@
|
||||
package priv.pront.code.mati.province;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* @Description:
|
||||
* @Author: pront
|
||||
* @Time:2023-11-11 17:01
|
||||
*/
|
||||
public class MC0203_小玛哥的艰难抉择 {
|
||||
|
||||
static class Info {
|
||||
private String name;
|
||||
private Integer value;
|
||||
private Integer time;
|
||||
|
||||
public Integer getTime() {
|
||||
return time;
|
||||
}
|
||||
|
||||
public void setTime(Integer time) {
|
||||
this.time = time;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public Integer getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public void setValue(Integer value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public Info(String name, Integer value, Integer time) {
|
||||
this.name = name;
|
||||
this.value = value;
|
||||
this.time = time;
|
||||
}
|
||||
}
|
||||
|
||||
static List<Info> list = new ArrayList<>();
|
||||
static int n;
|
||||
static Set<String> set = new HashSet<>();
|
||||
|
||||
public static void main(String[] args) {
|
||||
Scanner scanner = new Scanner(System.in);
|
||||
n = scanner.nextInt();
|
||||
|
||||
for (int i = 0; i < n; i++) {
|
||||
String s = scanner.next();
|
||||
int value = scanner.nextInt();
|
||||
if (!set.contains(s)) {
|
||||
list.add(new Info(s, value, i));
|
||||
set.add(s);
|
||||
continue;
|
||||
}
|
||||
for (Info info : list) {
|
||||
String name = info.getName();
|
||||
if(name.equals(s)){
|
||||
info.setValue(value + info.getValue());
|
||||
info.setTime(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int score = 10000;
|
||||
String flower = "";
|
||||
int time = 10000;
|
||||
for (Info cur : list) {
|
||||
String key = cur.getName();
|
||||
Integer value = cur.getValue();
|
||||
if (score > value) {
|
||||
score = value;
|
||||
flower = key;
|
||||
}else if(score == value && time > cur.time){
|
||||
time = cur.getTime();
|
||||
score = value;
|
||||
flower = key;
|
||||
}
|
||||
}
|
||||
|
||||
System.out.println(flower);
|
||||
System.out.println(1000 + score);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user