当前位置:网站首页>The 16th Heilongjiang Provincial Collegiate Programming Contest
The 16th Heilongjiang Provincial Collegiate Programming Contest
2022-06-30 21:10:00 【WDLieqi】
Catalog
D - Doin’ Time
Topic ideas
It can be used as an exercise interval dp The revised template question of .Title code
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int N = 310;
const int mod = 1000003;
int n;
LL p[N];
LL s[N][N], f[N][N];
int main()
{
cin >> n;
for (int i = 1; i <= n; i ++)
cin >> p[i];
for (int i = 1; i <= n; i ++)
{
LL t = 1;
for (int j = i; j <= n; j ++)
t = (t * p[j]) % mod, s[i][j] = t;
}
for (int len = 2; len <= n; len ++)
{
for (int i = 1; i + len - 1 <= n; i ++)
{
int l = i, r = i + len - 1;
f[l][r] = -1;
for (int k = l; k < r; k ++)
{
f[l][r] = max(f[l][r], f[l][k] + f[k + 1][r] + (s[i][k] - s[k + 1][r]) * (s[i][k] - s[k + 1][r]));
}
}
}
cout << f[1][n] << '\n';
return 0;
}
J - JOJO’s Factory
Topic ideas
Because the title has been given to M The scope of is Less than or equal to 2 * n - 3, So we can conclude that there must be no such thing as
4 6
1 1
1 2
1 3
2 1
2 2
2 3
Data like this , So it can be concluded that as long as it is not A It matches n individual B You must be able to pair them all .
Title code
#include <bits/stdc++.h>
using namespace std;
#define IOS \
ios::sync_with_stdio(false); \
cin.tie(0); \
cout.tie(0);
const int N = 5e5 + 10;
int ma[N], mb[N], n, m;
void solve()
{
cin >> n >> m;
int a = n, b = n;
while (m -- )
{
int x, y;
cin >> x >> y;
ma[x] ++;
mb[y] ++;
if (ma[x] >= n)
a --;
if (mb[y] >= n)
b --;
}
cout << min(a, b) << '\n';
}
int main()
{
IOS // If you don't, it will time out
int T = 1;
//cin >> T;
while (T--)
{
solve();
}
return 0;
}
K. Keep Eating
Topic ideas
We can put all the weight together first sum, Then eat it once 1 weight , In the end k individual , Just eat it k / 2 That's all right. , Pay attention to the special judgment sum Is it greater than k.
Title code
#include <bits/stdc++.h>
using namespace std;
#define IOS \
ios::sync_with_stdio(false); \
cin.tie(0); \
cout.tie(0);
void solve()
{
LL n, k;
cin >> n >> k;
LL res1 = 0, res2 = 0;
for (int i = 0; i < n; i ++)
{
int x;
cin >> x;
res1 += x;
}
if (res1 < k)
{
cout << 0 << '\n';
return;
}
res2 += res1 - k + k / 2;
cout << res2 << '\n';
}
int main()
{
IOS int T = 1;
//cin >> T;
while (T--)
{
solve();
}
return 0;
}
边栏推荐
- Electronic scheme development - Intelligent rope skipping scheme
- ArcMap|用字段计算器对不同类别的id赋值
- 19.04 distributor
- 利用日志服务器输出各种apache的日志的TOPN
- What about degradation of text generation model? Simctg tells you the answer
- 物联网僵尸网络Gafgyt家族与物联网设备后门漏洞利用
- C file pointer
- Radar data processing technology
- 【等级测评师】等级测评师怎么报名?多少分及格?
- 判断js对象是否为空的方式
猜你喜欢

ArcGIS构建发布简单路网Network数据服务及Rest调用测试

银行集体下架的智能投顾产品,为何成了“鸡肋”?

报错FileSystemException: /datas/nodes/0/indices/gtTXk-hnTgKhAcm-8n60Jw/1/index/.es_temp_file:结构需要清理

B_QuRT_User_Guide(33)

MySQL advanced 3

MFC界面库BCGControlBar v33.0 - 桌面警报窗口、网格控件升级等

Web APIs 综合案例-Tab栏切换 丨黑马程序员

毕业五年,想当初若没有入行测试,我是否还会如这般焦虑

偏向锁/轻量锁/重级锁锁锁更健康,上锁解锁到底是怎么完成实现的

在线教育项目用户登录和注册
随机推荐
Lumiprobe细胞生物学丨DiA,亲脂性示踪剂说明书
Learning summary
Move blog to CSDN
Amazon restricts LGBTQ related search and product sales in the United Arab Emirates
WebRTC系列-网络传输之本地scoket端口
Study on lumiprobe modified triphosphate biotin-11-utp
Game 81 biweekly
centos——开启/关闭oracle
Lumiprobe 改性三磷酸盐丨生物素-11-UTP研究
Double solid histogram / double y-axis
加密与解密以及OpenSSL的应用
遇到“word在试图打开文件时遇到错误”怎么办?
SqlServer 获取字符串中数字,中文及字符部分数据
科研中遇到迷茫困惑如何向前一步?如何在科研中发挥女性优势?
文本识别-SVTR论文解读
1.微信小程序页面跳转方法总结;2. navigateTo堆栈到十层不跳转问题
三个火枪手
uniapp-路由uni-simple-router
FreeRTOS记录(九、一个裸机工程转FreeRTOS的实例)
MySQL advanced 3