当前位置:网站首页>Brush questions - Luogu -p1047 trees outside the school gate
Brush questions - Luogu -p1047 trees outside the school gate
2022-07-25 13:46:00 【Song Xiangshang_ UP】
P1047 Trees outside the school gate -C Language
1、 subject

2、 The problem solving process
(1) for the first time Did not notice the problem of repeated areas
result :
Code :
(2) The second time
result :
Code :
// Luogu 3 P1047 Trees outside the school gate
#include <stdio.h>
#define TREE 10001// The maximum number of trees
int main() {
int l;// Road length
int m;// Number of areas 1<=m<=10
int u,v;// Area value
int tree_num=0;// The total number of trees
int tree_value[TREE] = {
0 };// Initialize the tree
int sum=0;// Number of roadside trees
int i;
int j;
scanf("%d %d", &l, &m);// Enter the length of the road and the number of areas
tree_num = l + 1;// The initial number of trees
for (i = 0; i < tree_num; i++) {
// Mark the tree
tree_value[i] = 1;
}
for (i = 0; i < m; i++) {
scanf("%d %d", &u, &v);
for (j = u; j <= v; j++) {
// Remove the trees in the area
tree_value[j] = 0;
}
}
for (i = 0; i < tree_num; i++) {
if (tree_value[i] == 1) {
sum++;
}
}
printf("%d", sum);
return 0;
}
边栏推荐
- Mujoco+spinningup for intensive learning training quick start
- 刷题-洛谷-P1089 津津的储蓄计划
- 高版本MySQL服务端安装不上怎么办,忘记密码(MySQL8.0.29)?
- Install oh my Zsh
- Applet starts wechat payment
- "Digital security" alert NFT's seven Scams
- Numpy quick start
- Package management apt, dpkg
- What should I do if the high-level MySQL server cannot be installed and I forget the password (MySQL 8.0.29)?
- The interviewer asked me: how much do you know about MySQL's storage engine?
猜你喜欢

ES6 array de duplication new set()

QGIS loading online map: Gaode, Tiandi map, etc

刷题-洛谷-P1085 不高兴的津津

In order to improve efficiency, there are various problems when using parallelstream

【力扣】645.错误的集合

MXNet对DenseNet(稠密连接网络)的实现

Excel add key run macro

Vscode plug-in development

刷题-洛谷-P1035 级数求和

Brush questions - Luogu -p1046 Tao Tao picking apples
随机推荐
Turn off automatic update when brew executes commands
刷题-洛谷-P1150 Peter的烟
刷题-洛谷-P1161 开灯
Workplace "digital people" don't eat or sleep 007 work system, can you "roll" them?
LabVIEW的内部错误
@Wrap decorator
C # basic learning (XXIII)_ Forms and events
Canvas judgment content is empty
2022年下半年软考信息安全工程师如何备考?
ES6 array de duplication new set()
刷题-洛谷-P1152 欢乐的跳
@wrap 装饰器
What should I do if the high-level MySQL server cannot be installed and I forget the password (MySQL 8.0.29)?
【力扣】1030.距离顺序排列矩阵单元格
刷题-洛谷-P1089 津津的储蓄计划
刷题-洛谷-P1146 硬币翻转
6.27 uniapp project history
hcip第八天实验
Mxnet implementation of densenet (dense connection network)
伯克利博士『机器学习工程』大实话;AI副总裁『2022 ML就业市场』分析;半导体创业公司大列表;大规模视频人脸属性数据集;前沿论文 | ShowMeAI资讯日报