版本比较
2025-08-23
正文
增加 3 行删除 3 行
14 行未改动15161718192021222314 行未改动3839404142434445464714 行未改动很简单,每一次合并芒果时都会在总数里选两个芒果合并,这个直接乘法原理组合数计算就行了。:::info[代码]#include <bits/stdc++.h>#define int long longusing namespace std;const int mod = 1e9 + 7, kN = 1e5 + 7;14 行未改动for (int i = 1, r = n; i <= r; i += 2, r++) {if (a[i] == 0 || a[i + 1] == 0) break;a[r + 1] = (a[i] + a[i + 1]) % mod, (ans1 += a[i] * a[i + 1] % mod) %= mod;}cout << ans1 << ' ' << op * ans2 << '\n';}return 0;}:::14 行未改动15161718192021222314 行未改动3839404142434445464714 行未改动很简单,每一次合并芒果时都会在总数里选两个芒果合并,这个直接乘法原理组合数计算就行了。:::info[代码]#include <bits/stdc++.h>#define int long longusing namespace std;const int mod = 1e9 + 7, kN = 1e5 + 7;14 行未改动for (int i = 1, r = n; i <= r; i += 2, r++) {if (a[i] == 0 || a[i + 1] == 0) break;a[r + 1] = (a[i] + a[i + 1]) % mod, (ans1 += a[i] * a[i + 1] % mod) %= mod;}cout << ans1 << ' ' << op * ans2 << '\n';}return 0;}:::