POJ 2665
1 #include<iostream> 2 #include<stdio.h> 3 using namespace std; 4 5 int main() 6 { 7 //freopen("acm.acm","r",stdin); 8 int tree; 9 int num; 10 int sum; 11 int a,b; 12 while(1) 13 { 14 cin>>tree; 15 cin>>num; 16 if(!tree && !num) 17 break; 18 ++ tree; 19 sum = 0; 20 while(num --) 21 { 22 cin>>a; 23 cin>>b; 24 sum += b - a + 1; 25 } 26 cout<<tree - sum<<endl; 27 } 28 }