【2020杭电多校】 Lead of Wisdom、The Oculus
阅读原文时间:2023年07月08日阅读:4

题目链接:Lead of Wisdom

题意:有n个物品,这些物品有k种类型。每种物品有对应的类型ti,其他值ai,bi,ci,di

你可以选择一些物品,但是这些物品要保证它们任意两者之间类型不能相同,即ti != tj。最后输出最大的DMG

题解:

如果输入的物品总类型数量有ans种,那么肯定是选择ans个物品最后的DMG最大,怎么选ans个物品,就暴力枚举就行

代码:

1 #include
2 #include
3 #include
4 #include
5 #include
6 #include
7 #include
8 #include
9 #include
10 #include
11 #include
12 using namespace std;
13 typedef long long ll;
14 const int maxn=65;
15 const int eps=1e-6;
16 struct Node
17 {
18 ll a, b, c, d;
19 } p;
20 vector vec[maxn];
21 ll vis[maxn];
22 ll dfs(ll u, ll a, ll b, ll c, ll d, ll now)
23 {
24 if (u == now + 1)
25 {
26 return (100 + a) * (100 + b) * (100 + c) * (100 + d);
27 }
28 ll n = vec[u].size();
29 ll ans = 0;
30 for (ll i = 0; i < n; i++) 31 { 32 p = vec[u][i]; 33 ans = max(ans, dfs(u + 1, a + p.a, b + p.b, c + p.c, d + p.d, now)); 34 } 35 return ans; 36 } 37 int main() 38 { 39 ios::sync_with_stdio(false); 40 cin.tie(0); 41 int t; 42 ll ans = 1; 43 for (int i = 0; i < 16; i++) 44 ans *= 3; 45 cout << ans << endl; 46 cin >> t;
47 while (t--)
48 {
49 ll n, k, cnt = 0;
50 cin >> n >> k;
51 for (ll i = 1; i <= n; i++) 52 vec[i].clear(), vis[i] = 0; 53 for (ll i = 0; i < n; i++) 54 { 55 ll kind, a, b, c, d; 56 cin >> kind >> a >> b >> c >> d;
57 if (!vis[kind])
58 vis[kind] = ++cnt;
59 vec[vis[kind]].push_back({a, b, c, d});
60 }
61 cout << dfs(1, 0, 0, 0, 0, cnt) << endl;
62 }
63 }

题目链接:The Oculus

题意:

定义一个斐波那契新数列,F[1]=1,F[2]=[2],F[n]=F[n-1]+F[n-2]

一个数x可有斐波那契数列得出,例如 4 = (1*1+2*0+3*1)    5 = (1*0+2*0+3*0+5*1),所以
4=(1,0,1), 5=(0,0,0,1)就是4、5的斐波那契数列

那么题目给你一个数A和数B的斐波那契数列,给你一个大于数C(A*B=C)的斐波那契数列,让你修改一下这个数列中某位的值,使得得到真的C的斐波那契数列。

最后输出你修改的是数列中那位的值

代码:

1 #include
2 #include
3 #include
4 #include
5 #include
6 #include
7 #include
8 #include
9 #include
10 #include
11 #include
12 using namespace std;
13 typedef long long ll;
14 typedef unsigned long long ull;
15 const int maxn=2e6+10;
16 const int eps=1e-6;
17 ull dp[maxn];
18 int main()
19 {
20 ios::sync_with_stdio(false);
21 cin.tie(0);
22 dp[1] = 1ull, dp[2] = 2ull;
23 for (ull i = 3; i > t;
27 while (t--)
28 {
29 ull a, b, c, res = 0, ans = 0, cra = 0, x;
30 cin >> a;
31 for (ull i = 1; i <= a; i++) 32 { 33 cin >> x;
34 if (x == 1)
35 res += dp[i];
36 }
37 cin >> b;
38 for (ull i = 1; i <= b; i++) 39 { 40 cin >> x;
41 if (x == 1)
42 ans += dp[i];
43 }
44 cin >> c;
45 for (ull i = 1; i <= c; i++) 46 { 47 cin >> x;
48 if (x == 1)
49 cra += dp[i];
50 }
51 ans *= res;
52 ull j = 1;
53 while (cra != ans-dp[j])
54 j++;
55 cout << j << endl;
56 }
57 }