POJ 2665 Trees(水题)

【题意简述】:就是有一段路上有和长度加一的值相等的数目,现在要在这条路上修路,所以要砍掉一些树,问剩下了多少树。

【分析】:很简单,注意一的处理就好。

//216K 79Ms
#include<iostream>
using namespace std;

int main()
{
	int len,n,s,e;
	while(cin>>len>>n)
	{
		int sum = 0;
		if(len == 0&&n == 0)
			break;
		for(int i = 0;i<n;i++)
		{
			cin>>s>>e;
			sum+=e-s+1;//注意+1
		}
		cout<<len+1 - sum<<endl;
	}
	return 0;
}
时间: 2024-09-30 19:43:47

POJ 2665 Trees(水题)的相关文章

POJ百道水题列表

以下是poj百道水题,新手可以考虑从这里刷起 搜索1002 Fire Net1004 Anagrams by Stack1005 Jugs1008 Gnome Tetravex1091 Knight Moves1101 Gamblers1204 Additive equations 1221 Risk1230 Legendary Pokemon1249 Pushing Boxes 1364 Machine Schedule1368 BOAT1406 Jungle Roads1411 Annive

poj 3264 RMQ 水题

题意:找到一段数字里最大值和最小值的差 水题 1 #include<cstdio> 2 #include<iostream> 3 #include<algorithm> 4 #include<cstring> 5 #include<cmath> 6 #include<queue> 7 using namespace std; 8 const int maxn=550; 9 const int INF=0x3f3f3f3f; 10 in

poj 1979 dfs水题

// 练练水题,夯实基础吧 #include <algorithm> #include <bitset> #include <cassert> #include <cctype> #include <cfloat> #include <climits> #include <cmath> #include <complex> #include <cstdio> #include <cstdlib

POJ 1000(水题)

这道题就很水啦,只要看懂题...所以我受了这个影响,再去hoj的时候想都没想就还按照这个打了,结果就像之前那篇说的那样WA. #include <stdio.h> int main() { int a,b; scanf("%d %d",&a, &b); printf("%d\n",a+b); return 0; }

Codechef December Challenge 2014 Chef and Apple Trees 水题

Chef and Apple Trees Chef loves to prepare delicious dishes. This time, Chef has decided to prepare a special dish for you, and needs to gather several apples to do so. Chef has N apple trees in his home garden. Each tree has a certain (non-zero) num

POJ 2665 Trees

Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 10075   Accepted: 6622 Description The road off the east gate of Peking University used to be decorated with a lot of trees. However, because of the construction of a subway, a lot of them

POJ - 3090 gcd水题

大概题意就是求\(1 \le i,j \le n\)的\(gcd(i,j) = 1\)的个数+2(对于0的特判) 正解应该是欧拉函数或者高逼格的莫比乌斯反演 但数据实在太水直接打表算了 /*H E A D*/ bool GCD[1002][1002]; inline int gcd(int a,int b){return b?gcd(b,a%b):a;} int main(){ rep(i,1,1000) rep(j,1,1000) GCD[i][j]=bool(gcd(i,j)==1); in

POJ - 3094 - Quicksum = 水题

http://poj.org/problem?id=3094 学习fgets的使用,注意fgets是会连换行一起保存的. #include<algorithm> #include<cmath> #include<cstdio> #include<cstring> #include<iostream> #include<map> #include<set> #include<stack> #include<

POJ 2365 Rope(水题)

[题意简述]:给出我们钉子个数与半径,让我们求出缠绕在钉子上的绳子有多长. [分析]:从题目中我们可以看出,绳子长度的和等于每两个钉子的距离的和加上接触在钉子上的绳子的长度,不难发现这部分长度其实就等于钉子的周长. 见代码: #include<iostream> #include<cmath> using namespace std; #define Pi 3.1415//这个精度要尽量高! 也可以用4.0*atan(1.0) double s(double x1,double y