当前位置:网站首页>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;
}
边栏推荐
- ES6 array de duplication new set()
- 手写jdbc的使用步骤?
- 【服务器数据恢复】HP EVA服务器存储RAID信息断电丢失的数据恢复
- 刷题-洛谷-P1089 津津的储蓄计划
- Install mujoco and report an error: distutils.errors DistutilsExecError: command ‘gcc‘ failed with exit status 1
- Introduction to jupyter notebook
- G027-op-ins-rhel-04 RedHat openstack creates a customized qcow2 format image
- 电脑里一辈子都不想删的神仙软件
- stable_baselines快速入门
- 2022年下半年软考信息安全工程师如何备考?
猜你喜欢

How can information security engineers prepare for the soft exam in the second half of 2022?

Brush questions - Luogu -p1046 Tao Tao picking apples

Applet sharing function

运动豪华还是安全豪华?亚洲龙与沃尔沃S60该入手哪款?

0710RHCSA

「数字安全」警惕 NFT的七大骗局

ES6 array de duplication new set()

window unbutu20 LTS apt,wget 安装时 DNS 解析错误
![Serious [main] org.apache.catalina.util.lifecyclebase Handlesubclassexception initialization component](/img/39/6f6760e80acec0b02028ea2ed1a5b1.png)
Serious [main] org.apache.catalina.util.lifecyclebase Handlesubclassexception initialization component

Pytest.mark.parameterize and mock use
随机推荐
手写jdbc的使用步骤?
The migration of arm architecture to alsa lib and alsa utils is smooth
电脑里一辈子都不想删的神仙软件
Mutex lock, spin lock, read-write lock... Clarify their differences and applications
Sports luxury or safety luxury? Which type of Asian Dragon and Volvo S60 should we start with?
QGIS loading online map: Gaode, Tiandi map, etc
伯克利博士『机器学习工程』大实话;AI副总裁『2022 ML就业市场』分析;半导体创业公司大列表;大规模视频人脸属性数据集;前沿论文 | ShowMeAI资讯日报
How happy is the frisbee bureau? 2022 youth trendy Sports Report
刷题-洛谷-P1046 陶陶摘苹果
Workplace "digital people" don't eat or sleep 007 work system, can you "roll" them?
What should I do if the high-level MySQL server cannot be installed and I forget the password (MySQL 8.0.29)?
Namespaces and libraries
6.27 uniapp project history
Mxnet implementation of densenet (dense connection network)
Hcip day 9 notes
Error of Tencent cloud [100007] this env is not enable anonymous login
Uncaught SyntaxError: Octal literals are not allowed in strict mode.
Applet H5 get mobile number scheme
mujoco_ Py Chinese document
刷题-洛谷-P1150 Peter的烟