//简单....
1 #include<iostream> 2 #include<cstdio> 3 #include<cstdlib> 4 using namespace std; 5 6 #define maxn 105 7 8 struct t 9 { 10 int s; 11 int e; 12 }; 13 14 t T[maxn]; 15 int cmp(const void *_p,const void *_q) 16 { 17 t *p = (t *)_p; 18 t *q = (t *)_q; 19 return p->e - q->e; 20 } 21 22 int n; 23 int main() 24 { 25 int res; 26 int cur; 27 while(scanf("%d",&n) && n) 28 { 29 for(int i = 0; i < n; i++) 30 scanf("%d%d",&T[i].s,&T[i].e); 31 qsort(T,n,sizeof T[0],cmp); 32 cur = T[0].e; 33 res = 1; 34 for(int i = 1; i < n; i++) 35 { 36 if(T[i].s >= cur) 37 { 38 cur = T[i].e; 39 res++; 40 } 41 } 42 printf("%d\n",res); 43 } 44 return 0; 45 }