武功秘籍 蓝桥杯
Description
小明到X山洞探险,捡到一本有破损的武功秘籍(2000多页!当然是伪造的)。
他注意到:书的第10页和第11页在同一张纸上,但第11页和第12页不在同一张纸上 。
小明只想练习该书的第a页到第b页的武功,又不想带着整本书。请问他至少要撕下多少张纸带走?
Input
有多组测试实例,输入小明想要练习的起始页a和末尾页b。(a<b)
Output
输出小明最少要带走的纸张,每行对应一个输出结果。
Sample Input
1 |
81 92 |
Sample Output
1 2 |
7 [codesyntax lang="c++"] |
1 2 3 4 5 6 7 8 9 10 11 12 |
#include 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;="" <="" pre="">[/codesyntax] |