版本比较
12.7总结
正文
增加 9 行删除 9 行
34 行未改动35363738394041424344454647484950515253545556575859606162636429 行未改动9495969798991001011024 行未改动10710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813934 行未改动signed main() {ios::sync_with_stdio(false);cin.tie(0), cout.tie(0);// 预处理dp[1] = 8;dp1[1] = 1;for (int i = 2; i <= 100000; i++) {dp[i] = (dp[i - 1] * 9 + dp1[i - 1]) % MOD;dp1[i] = (dp1[i - 1] * 9 + dp[i - 1]) % MOD;}int t;cin >> t;while (t--) {int n, k;cin >> n >> k;if (n == 1) {cout << 9 << "\n";} else {cout << dp[n] << "\n";}}return 0;}```# P2196 [NOIP 1996 提高组] 挖地雷29 行未改动for (int j = i + 1; j <= n; j++) {cin >> g[i][j];}}for (int i = 1; i <= n; i++) {dp[i] = a[i];pre[i] = 0;for (int j = 1; j < i; j++) {4 行未改动}}}}stack<int> st;int pos = 0, ans = 0;for (int i = 1; i <= n; i++) {if (dp[i] > ans) {ans = dp[i];pos = i;}}while (pos) {st.push(pos);pos = pre[pos];}while (!st.empty()) {cout << st.top();st.pop();if (!st.empty()) {cout << ' ';}}cout << endl << ans << endl;return 0;}```#### 时间复杂度20+400+400+20+20+20 = 88034 行未改动35363738394041424344454647484950515253545556575859606162636429 行未改动9495969798991001011024 行未改动10710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813934 行未改动signed main() {ios::sync_with_stdio(false);cin.tie(0), cout.tie(0);// 预处理dp[1] = 8;dp1[1] = 1;for (int i = 2; i <= 100000; i++) {dp[i] = (dp[i - 1] * 9 + dp1[i - 1]) % MOD;dp1[i] = (dp1[i - 1] * 9 + dp[i - 1]) % MOD;}int t;cin >> t;while (t--) {int n, k;cin >> n >> k;if (n == 1) {cout << 9 << "\n";} else {cout << dp[n] << "\n";}}return 0;}```# P2196 [NOIP 1996 提高组] 挖地雷29 行未改动for (int j = i + 1; j <= n; j++) {cin >> g[i][j];}}for (int i = 1; i <= n; i++) {dp[i] = a[i];pre[i] = 0;for (int j = 1; j < i; j++) {4 行未改动}}}}stack<int> st;int pos = 0, ans = 0;for (int i = 1; i <= n; i++) {if (dp[i] > ans) {ans = dp[i];pos = i;}}while (pos) {st.push(pos);pos = pre[pos];}while (!st.empty()) {cout << st.top();st.pop();if (!st.empty()) {cout << ' ';}}cout << endl << ans << endl;return 0;}```#### 时间复杂度20+400+400+20+20+20 = 880