当前位置:网站首页>刷题-洛谷-P1047 校门外的树
刷题-洛谷-P1047 校门外的树
2022-07-25 13:32:00 【宋向上_UP】
P1047 校门外的树-C语言
1、题目

2、解题过程
(1)第一次 没有注意到重复区域问题
结果:
代码:
(2)第二次
结果:
代码:
//洛谷3 P1047 校门外的树
#include <stdio.h>
#define TREE 10001//树的最大数目
int main() {
int l;//马路长度
int m;//区域数 1<=m<=10
int u,v;//区域数值
int tree_num=0;//树的总数
int tree_value[TREE] = {
0 };//对树进行初始化
int sum=0;//路边树的数目
int i;
int j;
scanf("%d %d", &l, &m);//输入马路长度和区域数
tree_num = l + 1;//树的初始数目
for (i = 0; i < tree_num; i++) {
//对树进行标记
tree_value[i] = 1;
}
for (i = 0; i < m; i++) {
scanf("%d %d", &u, &v);
for (j = u; j <= v; j++) {
//对区域内的树进行移除
tree_value[j] = 0;
}
}
for (i = 0; i < tree_num; i++) {
if (tree_value[i] == 1) {
sum++;
}
}
printf("%d", sum);
return 0;
}
边栏推荐
- [six articles talk about scalablegnn] around www 2022 best paper PASCA
- 【GCN-RS】Learning Explicit User Interest Boundary for Recommendation (WWW‘22)
- Error: cannot find or load main class XXXX
- Convolutional neural network model -- lenet network structure and code implementation
- Friends let me see this code
- Excel录制宏
- 业务可视化-让你的流程图'Run'起来(3.分支选择&跨语言分布式运行节点)
- 0715RHCSA
- 程序员成长第二十七篇:如何评估需求优先级?
- 为提高效率使用ParallelStream竟出现各种问题
猜你喜欢
随机推荐
【GCN-RS】Learning Explicit User Interest Boundary for Recommendation (WWW‘22)
Hcip day 8 notes
详解浮点数的精度问题
C # basic learning (XXIII)_ Forms and events
基于百问网IMX6ULL_PRO开发板移植LCD多点触摸驱动(GT911)
全网最简单解决方式1045-Access denied for user [email protected](using password:YES)
【GCN-CTR】DC-GNN: Decoupled GNN for Improving and Accelerating Large-Scale E-commerce Retrieval WWW22
【AI4Code】《Pythia: AI-assisted Code Completion System》(KDD 2019)
Convolutional neural network model -- alexnet network structure and code implementation
Any time, any place, super detective, seriously handle the case!
0716RHCSA
Numpy简介和特点(一)
Redis可视化工具RDM安装包分享
央行数研所穆长春:数字人民币可控匿名是维护公众利益和金融安全的客观需要
6W+字记录实验全过程 | 探索Alluxio经济化数据存储策略
Prepare for 2022 csp-j1 2022 csp-s1 preliminaries video set
Convolutional neural network model -- googlenet network structure and code implementation
arm架构移植alsa-lib和alsa-utils一路畅通
Mujoco+spinningup for intensive learning training quick start
vim基础操作汇总








