Skip to content

Commit aad0bcf

Browse files
committed
Merge branch 'develop' into 'master' for release v0.0.4
Signed-off-by: Certseeds <51754303+Certseeds@users.noreply.github.com>
2 parents 7d3c07d + cf0e125 commit aad0bcf

File tree

96 files changed

+1999
-32
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

96 files changed

+1999
-32
lines changed

.github/workflows/release.yml

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -92,13 +92,12 @@ jobs:
9292
echo $(pwd)
9393
9494
- name: release
95-
uses: marvinpinto/action-automatic-releases@latest
95+
uses: softprops/action-gh-release@v1
96+
if: startsWith(github.ref, 'refs/tags/')
9697
with:
97-
repo_token: ${{ secrets.GITHUB_TOKEN }}
98-
automatic_release_tag: ${{steps.branch_name.outputs.SOURCE_TAG}}
99-
prerelease: false
100-
title: ${{steps.branch_name.outputs.SOURCE_TAG}}
10198
files: ./../script_no_need.zip
99+
prerelease: false
100+
generate_release_notes: true
102101

103102
- name: tree
104103
run: tree

.husky/pre-commit

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#!/usr/bin/env bash
2-
set -x
2+
set -euox pipefail
33
main() {
44
./mvnw.sh clean
55
./mvnw.sh compile

2018fall/lab_2/README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
---
2+
SPDX-License-Identifier: CC-BY-NC-SA-4.0
3+
---
4+
5+
# lab_2
6+
7+
1. 这一部分可以看出, 一场Contest里面的标注的难易程度和标明的可能没大关系, 不过, 当然也可能和`/problem.php?id=${id}`也没啥关系就是了.
8+
9+
2. 测试后, 可以发现不给testcase数量的, 没法直接用控制台来测试, 需要用junit去读文件, 可能是文件里包含EOF的原因吧.
10+
11+
3. 快读的板子稍微修改之后也可以使用, 加一个函数而已.

2018fall/lab_2/lab_2_1129/pom.xml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0"
3+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
4+
<modelVersion>4.0.0</modelVersion>
5+
6+
<parent>
7+
<groupId>nanoseeds.CS203_DSAA_template_java.2018fall</groupId>
8+
<artifactId>lab_2</artifactId>
9+
<version>${revision}</version>
10+
<relativePath>./../pom.xml</relativePath>
11+
</parent>
12+
<groupId>nanoseeds.CS203_DSAA_template_java.2018fall.lab2</groupId>
13+
<artifactId>lab_2_1129</artifactId>
14+
<version>${revision}</version>
15+
<name>${project.groupId}.${project.artifactId}</name>
16+
<description>${project.groupId}.${project.artifactId}</description>
17+
18+
<build>
19+
<sourceDirectory>${project.basedir}/src</sourceDirectory>
20+
<testSourceDirectory>${project.basedir}/test</testSourceDirectory>
21+
</build>
22+
</project>
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
3
2+
100
3+
200
4+
300
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Case 1: -193.3774
2+
Case 2: -448.1475
3+
Case 3: -729.3383
Lines changed: 147 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,147 @@
1+
// SPDX-License-Identifier: AGPL-3.0-or-later
2+
/*
3+
CS203_DSAA_template
4+
5+
Copyright (C) 2023 nanos Certseeds
6+
*/
7+
8+
import java.io.BufferedReader;
9+
import java.io.IOException;
10+
import java.io.InputStreamReader;
11+
import java.util.ArrayList;
12+
import java.util.List;
13+
import java.util.Scanner;
14+
import java.util.StringTokenizer;
15+
import java.util.stream.Collectors;
16+
17+
public final class Main {
18+
// f'(0) = -2y, 说明肯定是先减
19+
// f'(100) = 5*10^14 + ... - 200y(<= 2*10^12) > 0,到最后递增
20+
// find where f'(x) equals to 0
21+
private static final class funcer {
22+
public funcer(double y) {
23+
this.y = y;
24+
}
25+
26+
private final double y;
27+
28+
public void setPosi(double posi) {
29+
this.posi = posi;
30+
}
31+
32+
private double posi = 0;
33+
34+
public double level0() {
35+
final double x = posi;
36+
assert ((0 <= x) && (x <= 100));
37+
return ((((5 * x + 6) * x * x * x + 3) * x + 4) * x - 2 * y) * x;
38+
}
39+
40+
public double level1(double x) {
41+
assert ((0 <= x) && (x <= 100));
42+
return (((35 * x + 36) * x * x * x + 9) * x + 8) * x - 2 * y;
43+
}
44+
45+
}
46+
47+
public static List<funcer> read() {
48+
final var input = new Scanner(System.in);
49+
final int testcases = input.nextInt();
50+
assert ((1 <= testcases) && (testcases <= 100));
51+
final var cases = new ArrayList<funcer>(testcases);
52+
for (int i = 0; i < testcases; i++) {
53+
final double number = input.nextDouble();
54+
assert ((0 < number) && (number < Math.pow(10, 10)));
55+
cases.add(new funcer(number));
56+
}
57+
return cases;
58+
}
59+
60+
public static List<funcer> reader() {
61+
final var input = new Reader();
62+
final int testcases = input.nextInt();
63+
assert ((1 <= testcases) && (testcases <= 100));
64+
final var cases = new ArrayList<funcer>(testcases);
65+
for (int i = 0; i < testcases; i++) {
66+
final double number = input.nextDouble();
67+
assert ((0 < number) && (number < Math.pow(10, 10)));
68+
cases.add(new funcer(number));
69+
}
70+
return cases;
71+
}
72+
73+
private static final double minidiff = 0.0000_0000_0000_0000_1d; // step should smaller enough
74+
private static final double fivezero = 0.000_01d; // but just need five or six
75+
76+
public static List<funcer> cal(List<funcer> nums) {
77+
final List<funcer> results = nums.stream()
78+
.map(one -> {
79+
for (double begin = 0, end = 100; Math.abs(begin - end) > minidiff; ) {
80+
final double mid = (end - begin) / 2 + begin;
81+
final double value = one.level1(mid);
82+
if (Math.abs(value) < fivezero) {
83+
one.setPosi(mid);
84+
return one;
85+
} else if (value > 0) {
86+
end = mid - minidiff; // mid is too big
87+
} else {
88+
begin = mid + minidiff; // mid is too small
89+
}
90+
}
91+
return one;
92+
})
93+
.collect(Collectors.toUnmodifiableList());
94+
return results;
95+
}
96+
97+
public static void main(String[] args) throws IOException {
98+
final var datas = reader();
99+
final var result = cal(datas);
100+
output(result);
101+
}
102+
103+
public static void output(List<funcer> decides) {
104+
for (int i = 1; i <= decides.size(); i++) {
105+
System.out.printf("Case %d: %.4f\n", i, decides.get(i - 1).level0());
106+
}
107+
}
108+
109+
// refactor from https://github.com/Kattis/kattio/blob/master/Kattio.java
110+
// url: https://raw.githubusercontent.com/Kattis/kattio/master/Kattio.java
111+
// license: MIT
112+
private static final class Reader {
113+
private final BufferedReader br;
114+
private StringTokenizer st;
115+
116+
private Reader() {
117+
br = new BufferedReader(new InputStreamReader(System.in));
118+
}
119+
120+
String next() {
121+
while (st == null || !st.hasMoreElements()) {
122+
try {
123+
st = new StringTokenizer(br.readLine());
124+
} catch (IOException e) {
125+
e.printStackTrace();
126+
}
127+
}
128+
return st.nextToken();
129+
}
130+
131+
int nextInt() {return Integer.parseInt(next());}
132+
133+
long nextLong() {return Long.parseLong(next());}
134+
135+
double nextDouble() {return Double.parseDouble(next());}
136+
137+
String nextLine() {
138+
String str = "";
139+
try {
140+
str = br.readLine();
141+
} catch (IOException e) {
142+
e.printStackTrace();
143+
}
144+
return str;
145+
}
146+
}
147+
}
File renamed without changes.

2018fall/lab_2/lab_2_1131/pom.xml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0"
3+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
4+
<modelVersion>4.0.0</modelVersion>
5+
6+
<parent>
7+
<groupId>nanoseeds.CS203_DSAA_template_java.2018fall</groupId>
8+
<artifactId>lab_2</artifactId>
9+
<version>${revision}</version>
10+
<relativePath>./../pom.xml</relativePath>
11+
</parent>
12+
<groupId>nanoseeds.CS203_DSAA_template_java.2018fall.lab2</groupId>
13+
<artifactId>lab_2_1131</artifactId>
14+
<version>${revision}</version>
15+
<name>${project.groupId}.${project.artifactId}</name>
16+
<description>${project.groupId}.${project.artifactId}</description>
17+
18+
<build>
19+
<sourceDirectory>${project.basedir}/src</sourceDirectory>
20+
<testSourceDirectory>${project.basedir}/test</testSourceDirectory>
21+
</build>
22+
</project>
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
2
2+
3 4
3+
1 2 3
4+
3 1
5+
1 2 3

0 commit comments

Comments
 (0)