武功秘籍 蓝桥杯

Description

小明到X山洞探险,捡到一本有破损的武功秘籍(2000多页!当然是伪造的)。
他注意到:书的第10页和第11页在同一张纸上,但第11页和第12页不在同一张纸上 。
小明只想练习该书的第a页到第b页的武功,又不想带着整本书。请问他至少要撕下多少张纸带走?
 

Input

有多组测试实例,输入小明想要练习的起始页a和末尾页b。(a<b)

Output

输出小明最少要带走的纸张,每行对应一个输出结果。

Sample Input

81 92

Sample Output

7
#include<iostream> 
using namespace std; 
int main() 
{int m,n,a; 
while(cin>>n>>m) 
{ 
    a=m-n+2; 
    a=a/2; 
    if(n%2!=0&&m%2==0) 
        a++; 
      
cout<<a<<endl; 
} 
  
  
return 0; 
} 
/************************************************************** 
    Problem: 2508 
    User: 201358505136 
    Language: C++ 
    Result: Accepted 
    Time:4 ms 
    Memory:1268 kb 
****************************************************************/ 


posted @ 2014-04-05 16:58  IT专业户  阅读(312)  评论(0编辑  收藏  举报