HNU Missing Pages

Source: Internet
Author: User

HNU Missing Pages

Missing Pages
Time Limit:2000 ms,Special Time Limit:5000 ms,Memory Limit:65536KB
Total submit users:78,Accepted users:78
Problem 12941:No special judgement
Problem description

Long ago, there were periodicals calledNewspapers, And these newspapers were printed onPaper, And people usedReadThem, and perhaps even share them. one unfortunate thing about this form of media is that every so often, someone wocould like an article so much, they wocould take it with them, leaving the rest of the newspaper behind for others to enjoy. unfortunately, because of the way that paper was folded, not only wocould the page with that article be gone, so wocould the page on the reverse side and also two other pages that were physically on the same sheet of folded paper.

For this problem we assume the classic approach is used for folding paper to make a booklet that has a number of pages that is a multiple of four. as an example, a newspaper with 12 pages wocould be made of three sheets of paper (see figure below ). one sheet wocould have pages 1 and 12 printed on one side, and pages 2 and 11 printed on the other. another piece of paper wowould have pages 3 and 10 printed on one side and 4 and 9 printed on the other. the third sheet wowould have pages 5, 6, 7, and 8.

When one numbered page is taken from the newspaper, the question is what other pages disappear.


Input <喎?http: www.bkjia.com kf ware vc " target="_blank" class="keylink"> Authorization + CjwvdHI + authorization + nc137ca8zw0 + TjwvZW0 + authorization + ms137ca8zw0 + UDwvZW0 + authorization + CjwvdHI + authorization = "brush: java; "> 12 212 98 30
Sample Output
1 11 123 4 104 5 6
Problem Source
ACM Mid-Central Programming Competition 2013
#include
     
      int main(){    int N,p,m,tp,p1,p2,p3;    while(scanf("%d",&N)>0&&N)    {        scanf("%d",&p);        m=N/4;        if(2*m>=p)        {            tp=(p+1)/2;            int k1=1,k2=N;            for(int i=2;i<=tp;i++)            k1+=2,k2-=2;            if(k1!=p)p1=k1;else p1=k1+1;            p2=k2-1; p3=k2;        }        else        {            tp=(p-m*2+1)/2;            int k1=m*2,k2=m*2+1;            for(int i=2;i<=tp;i++)            k1-=2,k2+=2;            if(k2!=p)p3=k2;else p3=k2+1;            p1=k1-1;p2=k1;        }        printf("%d %d %d\n",p1,p2,p3);    }}
     

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.