10/06改错

· · 个人记录

:::info[第 2 题: rune 符文石 (疑似错题)~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~]
:::info[第 4 题: julian 儒略历 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~]
### 1.题目大意:
日期大模拟题
- 1582 年以前和以后使用不同的闰年规则
- 1582 年 10 月 4 日的下一天直接变成 10 月 15 日。
### 2.思路:
不断进位。
### 3.代码:
~~~cpp
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll day = 1, month = 1, year = 1;
string s[] = {"DEC", "JAN", "FEB", "MAR", "APR", "MAY", "JUN", "JUL", "AUG", "SEP", "OCT", "NOV", "DEC"};
ll mon[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
bool isr(ll x) {
if (x <= 1582) return x % 4 == 0;
else if (x % 100 == 0) return x % 400 == 0;
else return x % 4 == 0;
}
int nian(ll x) {
if (x == 1582) return 355;
else if (isr(x)) return 366;
else return 365;
}
int yue(int ni, int yu) {
if (ni == 1582 && yu == 10) return 21;
if (yu == 2) {
if (isr(ni)) return mon[yu - 1] + 1;
else return mon[yu - 1];
} else return mon[yu - 1];
}
int main() {
ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
cin >> day;
day++;
while (day > nian(year)) {
day -= nian(year);
++year;
}
while (day > yue(year, month)) {
day -= yue(year, month);
++month;
}
cout << day << " " << s[month] << " " << year;
return 0;
}
~~~
ps:讨厌模拟。
:::
:::info[第 5 题: chess 西洋棋 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~]
### 1.题目大意:
在一个带权的网格中,棋子只能向下或向右,求最大路径的值和数量。
### 2.思路:
\large DP。
- 令 \large f_{i, j} 表示走到 \large (i, j) 的最大权值,易得 \large f_{i,j} = max(f_{i-1,j},f_{i,j-1})。
- 令 \large g_{i,j} 表示走到 (i,j) 的最大路径数量,因为只能从上方或左方转移,故继承 \large f_{i, j} 较大者,若相等则累加。
### 3.代码:
~~~cpp
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 2026;
const ll MOD = 1e9 + 7;
int n, m;
ll a[N][N];
ll dp[N][N];
ll cnt[N][N];
int main() {
ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
cin >> n >> m;
for (int i = 1; i <= n; ++i)
for (int j = 1; j <= m; ++j)
cin >> a[i][j];
dp[1][1] = a[1][1];
cnt[1][1] = 1;
for (int i = 1; i <= n; ++i) {
for (int j = 1; j <= m; ++j) {
if (i == 1 && j == 1) continue;
if (i == 1) {
dp[i][j] = dp[i][j - 1] + a[i][j];
cnt[i][j] = cnt[i][j - 1] % MOD;
} else if (j == 1) {
dp[i][j] = dp[i - 1][j] + a[i][j];
cnt[i][j] = cnt[i - 1][j] % MOD;
} else {
if (dp[i][j - 1] > dp[i - 1][j]) {
dp[i][j] = dp[i][j - 1] + a[i][j];
cnt[i][j] = cnt[i][j - 1];
} else if (dp[i - 1][j] > dp[i][j - 1]) {
dp[i][j] = dp[i - 1][j] + a[i][j];
cnt[i][j] = cnt[i - 1][j];
} else {
dp[i][j] = dp[i - 1][j] + a[i][j];
cnt[i][j] = (cnt[i][j - 1] + cnt[i - 1][j]) % MOD;
}
cnt[i][j] %= MOD;
}
}
}
cout << dp[n][m] << "\n" << cnt[n][m] % MOD;
return 0;
}
~~~
ps:注意边界!(a[i][j] < 0)
:::

:::info[第 6 题: puzzle 解迷题 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~]

1.题目大意:

用不同的斐波那契数组成数字 n,有多少种不同的方法。

2.思路:

枚举子集+剪枝。