黄海 1 year ago
commit 94518ff5a5

@ -96,18 +96,13 @@ $1≤n,m≤50$
因此,我们可以通过微调其中的一条路线,使之不经过重合点 $C$,同时路线的总价值没有减少
**得证**:最优解路线可以是不经过重复路线的 (部分证明方法参照了 [第一赞的题解](https://www.acwing.com/solution/content/12389/)了)
**得证**:最优解路线可以是不经过重复路线的
接下来就是完全参照 $AcWing$ $1027$. 方格取数 的$DP$分析了
关于 **重合格子** 判断一些条件都在这篇博客里详细写了
这里我偷个懒,直接用我上篇博客的内容了 ~~(既然是我自己写的应该不算抄袭吧!)~~
![20220930165932](https://cdn.jsdelivr.net/gh/littlehb/ShaoHuiLin/20220930165932.png)
### Code(三重迭代写法)
**集合划分**
<center><img src='https://cdn.acwing.com/media/article/image/2021/05/27/55909_2df58fe8be-IMG_623B17197D17-1.jpeg'></center>

@ -0,0 +1,20 @@
#include <bits/stdc++.h>
using namespace std;
int main() {
int n, m;
cin >> n >> m;
int cnt = 0;
for (int i = n; i <= m; i++) {
int x = i;
bool flag = false;
while (x) {
int a = x % 10;
if (a % 2 == 0) flag = true;
x /= 10;
}
if (!flag) cnt++;
}
cout << cnt << endl;
return 0;
}

@ -0,0 +1,18 @@
#include <iostream>
using namespace std;
int main() {
int n, cnt = 0;
cin >> n;
cnt = n / 3;
if (n == 2)
cnt = -1;
else if (n == 4)
cnt = 4;
else if (n % 3 == 1)
cnt += 1;
else if (n % 3 == 2)
cnt += 2;
cout << cnt << endl;
return 0;
}

@ -0,0 +1,3 @@
https://blog.csdn.net/qq_36230375/article/details/134725732
https://tiku.scratchor.com/paper/view/gjfvsjrgtpm30v3f

@ -0,0 +1,26 @@
#include <bits/stdc++.h>
using namespace std;
int k;
string kill(string s) {
int p = 0;
for (int i = 0; i < s.size() - 1; i++)
if (s[i + 1] > s[i]) {
p = i;
break;
}
string res;
for (int i = 0; i < s.size(); i++)
if (i != p) res += s[i];
return res;
}
int main() {
string s;
cin >> s;
cin >> k;
for (int i = 1; i <= k; i++) s = kill(s);
cout << s << endl;
return 0;
}

@ -0,0 +1,49 @@
#include <bits/stdc++.h>
using namespace std;
const int N = 100010;
vector<int> g[N]; // 邻接表,一个正图,一个反图
int c[N]; // 每个树洞中松鼠的数量
/*
4
5
3
6
1
1 2
1 3
2 4
2
*/
int dfs(int u, int fa, int k) {
if (k == 0) return c[u];
int sum = c[u];
for (int i = 0; i < g[u].size(); i++) {
if (g[u][i] == fa) continue;
sum += dfs(g[u][i], u, k - 1);
}
return sum;
}
int main() {
#ifndef ONLINE_JUDGE
freopen("11.in", "r", stdin);
#endif
int n; // 树洞的数量
cin >> n;
for (int i = 1; i <= n; i++) cin >> c[i]; // 每个树洞中松鼠的数量
for (int i = 1; i < n; i++) {
int a, b; // 表示两个树洞相连接
cin >> a >> b;
g[a].push_back(b); // 用邻接表保存一下某个树洞与哪两个其它树洞相连接
g[b].push_back(a);
}
int k;
cin >> k;
for (int i = 1; i <= n; i++) cout << dfs(i, -1, k) << endl;
return 0;
}

@ -0,0 +1,14 @@
#include <bits/stdc++.h>
using namespace std;
int func(int x, int y, int z) {
if (x == 1 || y == 1 || z == 1) return 1;
if (x < y && x < z)
return func(x, y - 1, z) + func(x, y, z - 1);
if (y < x && y < z)
return func(x - 1, y, z) + func(x, y, z - 1);
return func(x - 1, y, z) + func(x, y - 1, z);
}
int main() {
cout << func(3, 3, 2);
return 0;
}

@ -0,0 +1,36 @@
```cpp {.line-numbers}
int func( int x, int y, int z )
{
if( x == 1 || y == 1 || z == 1 ) return 1;
if( x < y && x < z )
return func( x, y - 1, z ) + func( x, y, z - 1 );
if( y < x && y < z )
return func( x - 1, y, z ) + func( x, y, z - 1 );
return func( x - 1, y, z ) + func( x, y - 1, z );
}
int main()
{
cout << func( 3, 3, 2 );
return 0;
}
```
将$func()$简写成$f()$
人脑模拟电脑
$f(3,3,2)=f(2,3,2)+f(3,2,2)$
其中
$f(2,3,2)=f(1,3,2)+f(2,2,2)$ ①
$f(3,2,2)=f(2,2,2)+f(3,1,2)$ ②
最终$res=①+②$
$f(1,3,2)=1$
$f(2,2,2)=f(1,2,2)+f(2,1,2)=1+1=2$
$\therefore$ ①=3
②=3
①+②=6

@ -0,0 +1,26 @@
#include <bits/stdc++.h>
using namespace std;
int main() {
string s;
cin >> s;
int m;
cin >> m;
m--;
while (m--) {
string t;
for (int i = 0; i < s.size(); i++) {
int c = 1;
while (i + 1 < s.size() && s[i + 1] == s[i]) {
c++;
i++;
}
t = t + to_string(c) + s[i];
}
s = t;
}
cout << s << endl;
return 0;
}

@ -0,0 +1 @@
https://tiku.scratchor.com/paper/view/z8k4y0xsf0ue8xlh

@ -1,27 +1,26 @@
#include <bits/stdc++.h>
using namespace std;
/**
8
4 2
1
2 2
3 3 3
4 4 4 4
*/
int n, sum;
int main() {
cin >> n;
for (int i = 1;; i++) {
n -= i;
if (n <= 0) {
// cout << i << " " << i + n << endl;
sum += i * (i + n); // 最后一行
for (int j = 1; j < i; j++) sum += j * j;
cout << sum << endl;
break;
string s;
cin >> s;
int m;
cin >> m;
m--;
while (m--) {
string t;
for (int i = 0; i < s.size(); i++) {
int c = 1;
while (i + 1 < s.size() && s[i + 1] == s[i]) {
c++;
i++;
}
t = t + to_string(c) + s[i];
}
s = t;
}
cout << s << endl;
return 0;
}
}

@ -5,19 +5,7 @@ https://www.lanqiaoqingshao.cn/home
黄琬乔
220105201212060427
办法
1、使用qq截图功能随意找一个聊天框然后点击小剪刀功能然后在图片的下方有一个识别文字的功能很好用。
截图快捷键: ctrl+alt+a
2、复制粘贴到ChatGPT,让它来帮助给出答案,但似乎有时它的回复不正确。
https://tongyi.aliyun.com/
kgdxpr@163.com
DsideaL4r5t6y7u!@#
(1) 用加速猫翻墙
(2) https://chat.forefront.ai/
superhuanghai@gmail.com
mdcija780522

Loading…
Cancel
Save