Problem and code:
/* *copyright (c) 2014, *allrightsreserved of the School of Computer and Control engineering, Yantai University. * File name: Wulinmiji.cpp * Author: Tan Xinxin * Date of Completion: December 12, 2014 * Version number: v1.0 * * Problem Description: Xiao Ming to the X Cave Adventure, picked up a broken martial arts cheats (more than 2000 pages. Of course it was forged). He noted that pages 10th and 11th of the book were on the same sheet of paper, but pages 11th and 12th were not on the same sheet. Xiaoming only wants to practise the martial arts of the book page A to page B, and does not want to carry the whole book. How many pieces of paper would he have to tear off at least? There are multiple sets of test instances, enter the start page A and end B of Xiaoming want to practice. (A<B). * Program output: The output of xiaoming at least to take away the paper, each row corresponds to an output result. * * #include <iostream> usingnamespacestd; Intmain () {inta,b,n; while (CIN>>A>>B)/multiple-input test case {n=b/2-a/2+1; cout<<n<<endl;} Return0;}
Run Result:
Summary of Knowledge points:
The ability to think and solve math problems is very important AH ah.
Learning experience:
You have to pay attention to a number of sets of test cases ah ah ah ... I was wrong five times because of this problem ah ah ...