Week 16th-martial arts Cheats

Source: Internet
Author: User


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 ...

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.