当前位置:网站首页>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;
}
边栏推荐
- 0717RHCSA
- Applet enterprise red envelope function
- LabVIEW的内部错误
- The whole process of 6w+ word recording experiment | explore the economical data storage strategy of alluxio
- MXNet对DenseNet(稠密连接网络)的实现
- Package management apt, dpkg
- 命名空间与库
- ES6 array de duplication new set()
- 百度搜索打击盗版网文站点,SEOer应该关注哪些问题?
- Error: cannot find or load main class XXXX
猜你喜欢

How happy is the frisbee bureau? 2022 youth trendy Sports Report

Okaleido上线聚变Mining模式,OKA通证当下产出的唯一方式

Redux usage and analysis

JS array indexof includes sort() colon sort quick sort de duplication and random sample random

刷题-洛谷-P1150 Peter的烟

ADB connects to Xiaomi mobile phone via Wi Fi

刷题-洛谷-P1151 子数整数

Applet starts wechat payment
![[configure hifive1 revb] the device manager does not recognize the port, and can not connect to j-link via USB](/img/55/a8acdd63a17bf9e3072c9a04babe79.png)
[configure hifive1 revb] the device manager does not recognize the port, and can not connect to j-link via USB

0716RHCSA
随机推荐
Leetcode 113. 路径总和 II
刷题-洛谷-P1089 津津的储蓄计划
hcip第八天笔记
MySQL 01: Source command
pycharm不能输入中文解决方法
leetcode1 --两数之和
uniapp处理后台传输图片
Hcip day 9 notes
6.27 uniapp项目历程
G027-op-ins-rhel-04 RedHat openstack creates a customized qcow2 format image
Install mujoco and report an error: distutils.errors DistutilsExecError: command ‘gcc‘ failed with exit status 1
Hcip day 6 notes
Online Learning and Pricing with Reusable Resources: Linear Bandits with Sub-Exponential Rewards: Li
Congestion control of TCP
Redux usage and analysis
Applet starts wechat payment
QGIS加载在线地图:高德、天地图等
【服务器数据恢复】HP EVA服务器存储RAID信息断电丢失的数据恢复
mujoco_py中文文档
stable_baselines快速入门