'commit'
This commit is contained in:
19
TangDou/Mkx/202412C1/1224.cpp
Normal file
19
TangDou/Mkx/202412C1/1224.cpp
Normal file
@@ -0,0 +1,19 @@
|
||||
#include <bits/stdc++.h>
|
||||
using namespace std;
|
||||
int main() {
|
||||
int a, b, c, d, x, y;
|
||||
cin >> a >> b >> c >> d >> x >> y;
|
||||
|
||||
for (int p = 100; p >= 0; p--) {
|
||||
int m = p + x;//数学
|
||||
int e = p - y;//英语
|
||||
if (m > 100) continue;
|
||||
if (e < 0) continue;
|
||||
int sum = a + b + c + d + m + e;
|
||||
if (sum % 6 == 0 && sum / 6 == p) {
|
||||
cout << p << endl;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
10
TangDou/Mkx/202412C1/4950.cpp
Normal file
10
TangDou/Mkx/202412C1/4950.cpp
Normal file
@@ -0,0 +1,10 @@
|
||||
#include <bits/stdc++.h>
|
||||
using namespace std;
|
||||
typedef long long LL;
|
||||
int main() {
|
||||
LL x, y;
|
||||
cin >> x >> y;
|
||||
|
||||
cout << 2 * (y + 3 * x) << endl;
|
||||
return 0;
|
||||
}
|
||||
59
TangDou/Mkx/202412C1/4950.md
Normal file
59
TangDou/Mkx/202412C1/4950.md
Normal file
@@ -0,0 +1,59 @@
|
||||
设马克家到学校的距离为 \( D \) 千米。马克和他爸爸第一次相遇时,他们共同走过的距离是 \( D \) 千米。由于他们第一次相遇在距离家、学校中点 \( x \) 千米靠家一侧,这意味着马克走了 \( \frac{D}{2} - x \) 千米,而他爸爸走了 \( \frac{D}{2} + x \) 千米。
|
||||
|
||||
第二次相遇时,他们共同走过的距离是 \( 3D \) 千米(因为他们各自走了一个来回,然后再次相遇)。此时,马克走了 \( D + y \) 千米,而他爸爸走了 \( 2D - y \) 千米。
|
||||
|
||||
由于他们的速度是恒定的,他们走过的距离之比在两次相遇时是相同的。因此,我们可以建立以下比例关系:
|
||||
|
||||
\[
|
||||
\frac{\frac{D}{2} - x}{\frac{D}{2} + x} = \frac{D + y}{2D - y}
|
||||
\]
|
||||
|
||||
交叉相乘得到:
|
||||
|
||||
\[
|
||||
\left( \frac{D}{2} - x \right) (2D - y) = \left( \frac{D}{2} + x \right) (D + y)
|
||||
\]
|
||||
|
||||
展开两边:
|
||||
|
||||
\[
|
||||
D^2 - \frac{Dy}{2} - 2Dx + xy = \frac{D^2}{2} + \frac{Dy}{2} + Dx + xy
|
||||
\]
|
||||
|
||||
简化方程,消去 \( xy \) 项:
|
||||
|
||||
\[
|
||||
D^2 - \frac{Dy}{2} - 2Dx = \frac{D^2}{2} + \frac{Dy}{2} + Dx
|
||||
\]
|
||||
|
||||
合并同类项:
|
||||
|
||||
\[
|
||||
D^2 - \frac{D^2}{2} - \frac{Dy}{2} - \frac{Dy}{2} - 2Dx - Dx = 0
|
||||
\]
|
||||
|
||||
\[
|
||||
\frac{D^2}{2} - Dy - 3Dx = 0
|
||||
\]
|
||||
|
||||
提取 \( D \):
|
||||
|
||||
\[
|
||||
D \left( \frac{D}{2} - y - 3x \right) = 0
|
||||
\]
|
||||
|
||||
由于 \( D \neq 0 \),我们有:
|
||||
|
||||
\[
|
||||
\frac{D}{2} - y - 3x = 0
|
||||
\]
|
||||
|
||||
解出 \( D \):
|
||||
|
||||
\[
|
||||
D = 2(y + 3x)
|
||||
\]
|
||||
|
||||
因此,马克家到学校的距离是 \(\boxed{2(y + 3x)}\) 千米。
|
||||
|
||||
此题最大的坑点:第一次相遇时,并不是到家再返回才相遇~~~
|
||||
44
TangDou/Mkx/202412C1/8703.cpp
Normal file
44
TangDou/Mkx/202412C1/8703.cpp
Normal file
@@ -0,0 +1,44 @@
|
||||
#include <bits/stdc++.h>
|
||||
using namespace std;
|
||||
// 高精度乘法
|
||||
const int N = 1e5 + 10;
|
||||
int a[N], al;
|
||||
void mul(int a[], int &al, int b) {
|
||||
int t = 0;
|
||||
for (int i = 1; i <= al; i++) {
|
||||
t += a[i] * b;
|
||||
a[i] = t % 10;
|
||||
t /= 10;
|
||||
}
|
||||
while (t) {
|
||||
a[++al] = t % 10;
|
||||
t /= 10;
|
||||
}
|
||||
// 去前导0
|
||||
while (al > 1 && !a[al]) al--;
|
||||
}
|
||||
|
||||
// 判断一个数是不是质数
|
||||
bool isPrime(int n) {
|
||||
if (n < 2) return false;
|
||||
for (int i = 2; i <= n / i; i++)
|
||||
if (n % i == 0) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
int main() {
|
||||
int n;
|
||||
cin >> n;
|
||||
|
||||
// 初始化
|
||||
a[++al] = 1;
|
||||
// 阶乘
|
||||
for (int i = 1; i <= n; i++) mul(a, al, i);
|
||||
|
||||
int sum = 0;
|
||||
// for (int i = al; i; i--) printf("%d", a[i]);
|
||||
for (int i = al; i; i--) sum += a[i];
|
||||
|
||||
cout << sum << " " << (isPrime(sum) ? "T" : "F") << endl;
|
||||
return 0;
|
||||
}
|
||||
20
TangDou/Mkx/202412C1/8705.cpp
Normal file
20
TangDou/Mkx/202412C1/8705.cpp
Normal file
@@ -0,0 +1,20 @@
|
||||
#include <bits/stdc++.h>
|
||||
using namespace std;
|
||||
const int N = 100010;
|
||||
struct Node {
|
||||
int score;
|
||||
string name;
|
||||
bool operator<(const Node &b) const {
|
||||
if (score == b.score) return name < b.name;
|
||||
return score > b.score;
|
||||
}
|
||||
} a[N];
|
||||
int main() {
|
||||
int n;
|
||||
cin >> n;
|
||||
for (int i = 1; i <= n; i++) cin >> a[i].name >> a[i].score;
|
||||
sort(a + 1, a + 1 + n);
|
||||
for (int i = 1; i <= n; i++)
|
||||
cout << a[i].name << " " << a[i].score << endl;
|
||||
return 0;
|
||||
}
|
||||
39
TangDou/Mkx/202412C1/8712.cpp
Normal file
39
TangDou/Mkx/202412C1/8712.cpp
Normal file
@@ -0,0 +1,39 @@
|
||||
#include <bits/stdc++.h>
|
||||
using namespace std;
|
||||
const int N = 110;
|
||||
int t[N], d[N];
|
||||
struct Node {
|
||||
int id;//第几只兔子
|
||||
int t;//跑一趟的消耗时间
|
||||
int d;//破坏力
|
||||
bool operator<(const Node &b) const {
|
||||
return d * 1.0 / t > b.d * 1.0 / b.t;
|
||||
}
|
||||
} a[N];
|
||||
|
||||
/*
|
||||
6
|
||||
3 1
|
||||
2 5
|
||||
2 3
|
||||
3 2
|
||||
4 1
|
||||
1 6
|
||||
*/
|
||||
int main() {
|
||||
int n;
|
||||
cin >> n;
|
||||
for (int i = 1; i <= n; i++) cin >> a[i].t >> a[i].d, a[i].id = i;
|
||||
sort(a + 1, a + n + 1);
|
||||
|
||||
// for (int i = 1; i <= n; i++) cout << a[i].id << " ";
|
||||
|
||||
// 计算破坏了多少花卉
|
||||
int sum = 0;
|
||||
for (int i = 1; i < n; i++)
|
||||
for (int j = i + 1; j <= n; j++)
|
||||
sum += a[j].d * a[i].t * 2;
|
||||
|
||||
cout << sum << endl;
|
||||
return 0;
|
||||
}
|
||||
42
TangDou/Mkx/202412C1/8741_1.cpp
Normal file
42
TangDou/Mkx/202412C1/8741_1.cpp
Normal file
@@ -0,0 +1,42 @@
|
||||
#include <bits/stdc++.h>
|
||||
using namespace std;
|
||||
const int N = 20;
|
||||
int n;
|
||||
/*
|
||||
4
|
||||
1 2
|
||||
1 3
|
||||
1 4
|
||||
1 5
|
||||
*/
|
||||
struct Node {
|
||||
int x, y;
|
||||
} b[N]; // 表示区域x和区域y之间存在公共边
|
||||
|
||||
bool check(int i, int j, int k, int p, int q) {
|
||||
vector<int> color = {0, i, j, k, p, q};
|
||||
for (int x = 1; x <= n; x++) {
|
||||
if (color[b[x].x] == color[b[x].y]) return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
int ans;
|
||||
int main() {
|
||||
cin >> n;
|
||||
for (int i = 1; i <= n; i++) cin >> b[i].x >> b[i].y;
|
||||
// 5个区域,4个颜色,构建每一组组合,不管是否合理都列出来
|
||||
for (int i = 1; i <= 4; i++)
|
||||
for (int j = 1; j <= 4; j++)
|
||||
for (int k = 1; k <= 4; k++)
|
||||
for (int p = 1; p <= 4; p++)
|
||||
for (int q = 1; q <= 4; q++) {
|
||||
// 此时的i,j,k,p,q表示5个区域的颜色
|
||||
// 判断是不是合理
|
||||
if (check(i, j, k, p, q))
|
||||
ans++;
|
||||
}
|
||||
|
||||
cout << ans << endl;
|
||||
return 0;
|
||||
}
|
||||
38
TangDou/Mkx/202412C1/8741_2.cpp
Normal file
38
TangDou/Mkx/202412C1/8741_2.cpp
Normal file
@@ -0,0 +1,38 @@
|
||||
#include <bits/stdc++.h>
|
||||
using namespace std;
|
||||
const int N = 15;
|
||||
int n, ans, color[N];
|
||||
|
||||
// N个公共边
|
||||
struct Node {
|
||||
int x, y;
|
||||
} a[N];
|
||||
|
||||
void dfs(int u) {
|
||||
if (u > 5) { // 判断
|
||||
bool flag = true;
|
||||
// 检查此时的安排是不是合理
|
||||
for (int i = 1; i <= n; i++) { // 遍历每个公共边
|
||||
if (color[a[i].x] == color[a[i].y]) { // 如果两个区域的颜色相同,则返回
|
||||
flag = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (flag) ans++; // 找到了一个新方案
|
||||
return;
|
||||
}
|
||||
// 枚举方案
|
||||
for (int i = 1; i <= 4; i++) {
|
||||
color[u] = i; // u这个区域放i这个颜色
|
||||
dfs(u + 1); // 走到下一个区域面前
|
||||
}
|
||||
}
|
||||
int main() {
|
||||
cin >> n;
|
||||
for (int i = 1; i <= n; i++) cin >> a[i].x >> a[i].y; // 区域x与区域y之间存在公共边
|
||||
// 开始搜索
|
||||
dfs(1);
|
||||
// 输出结果
|
||||
cout << ans << endl;
|
||||
return 0;
|
||||
}
|
||||
28
TangDou/Mkx/202412C1/8919.cpp
Normal file
28
TangDou/Mkx/202412C1/8919.cpp
Normal file
@@ -0,0 +1,28 @@
|
||||
#include <bits/stdc++.h>
|
||||
using namespace std;
|
||||
const int N = 1e6 + 10;
|
||||
typedef pair<int, int> PII;
|
||||
PII a[N];
|
||||
set<PII> s;
|
||||
|
||||
int main() {
|
||||
int n;
|
||||
cin >> n;
|
||||
int x1, ax, bx, cx;
|
||||
int y1, ay, by, cy;
|
||||
cin >> x1 >> ax >> bx >> cx;
|
||||
cin >> y1 >> ay >> by >> cy;
|
||||
// 第一个点进入集合
|
||||
a[1] = {x1, y1};
|
||||
s.insert(a[1]);
|
||||
|
||||
int idx = 1;
|
||||
while (s.size() < n) {
|
||||
int X = (a[idx].first * ax + bx + idx) % cx;
|
||||
int Y = (a[idx].second * ay + by + idx) % cy;
|
||||
a[++idx] = {X, Y};
|
||||
s.insert(a[idx]);
|
||||
}
|
||||
cout << idx << endl;
|
||||
return 0;
|
||||
}
|
||||
15
TangDou/Mkx/202412C1/试题地址.txt
Normal file
15
TangDou/Mkx/202412C1/试题地址.txt
Normal file
@@ -0,0 +1,15 @@
|
||||
Contest4950 - 2024-2025学年上学期C1结课测试
|
||||
http://www.accoders.com/contest.php?cid=4950
|
||||
|
||||
|
||||
网址:
|
||||
http://www.accoders.com/
|
||||
|
||||
题库accoders账号
|
||||
mkx202361
|
||||
|
||||
密码
|
||||
20232023
|
||||
|
||||
验证码
|
||||
accoders
|
||||
Reference in New Issue
Block a user