设为首页 加入收藏

TOP

HNU Missing Pages
2015-07-20 17:47:25 来源: 作者: 【 】 浏览:1
Tags:HNU Missing Pages
Missing Pages
Time Limit: 2000ms, Special Time Limit:5000ms, Memory Limit:65536KB
Total submit users: 78, Accepted users: 78
Problem 12941 : No special judgement
Problem description

Long ago, there were periodicals called newspapers, and these newspapers were printed on paper, and people used to read them, and perhaps even share them. One unfortunate thing about this form of media is that every so often, someone would like an article so much, they would 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 would the page with that article be gone, so would 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 would be made of three sheets of paper (see figure below). One sheet would have pages 1 and 12 printed on one side, and pages 2 and 11 printed on the other. Another piece of paper would have pages 3 and 10 printed on one side and 4 and 9 printed on the other. The third sheet would 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.2cto.com/kf/ware/vc/" target="_blank" class="keylink">vc3Ryb25nPjwvdGQ+CjwvdHI+Cjx0cj4KPHRkPgo8cD48c3Ryb25nPklucHV0Ojwvc3Ryb25nPiAgRWFjaCB0ZXN0IGNhc2Ugd2lsbCBiZSBkZXNjcmliZWQgd2l0aCB0d28gaW50ZWdlcnMgPGVtPgpOPC9lbT4gYW5kIDxlbT5QPC9lbT4sIG9uIGEgbGluZSwgd2hlcmUgPG5vYnI+NCCh3CA8ZW0+TjwvZW0+IKHcIDEwMDA8L25vYnI+IGlzIGEgbXVsdGlwbGUgb2YgZm91ciB0aGF0IGRlc2lnbmF0ZXMgdGhlIGxlbmd0aCBvZiB0aGUgbmV3c3BhcGVyIGluIHRlcm1zIG9mIG51bWJlcmVkIHBhZ2VzLCBhbmQKPG5vYnI+MSCh3CA8ZW0+UDwvZW0+IKHcIDxlbT5OPC9lbT48L25vYnI+IGlzIGEgcGFnZSB0aGF0IGhhcyBiZWVuIHRha2VuLiBUaGUgZW5kIG9mIHRoZSBpbnB1dCBpcyBkZXNpZ25hdGVkIGJ5IGEgbGluZSBjb250YWluaW5nIG9ubHkgdGhlIHZhbHVlIDAuCjwvcD4KPGJyPgo8L3RkPgo8L3RyPgo8dHI+Cjx0ZD48c3Ryb25nPk91dHB1dDwvc3Ryb25nPjwvdGQ+CjwvdHI+Cjx0cj4KPHRkPgo8cD48c3Ryb25nPk91dHB1dDo8L3N0cm9uZz4gIEZvciBlYWNoIGNhc2UsIG91dHB1dCwgaW4gaW5jcmVhc2luZyBvcmRlciwgdGhlIHBhZ2UgbnVtYmVycyBmb3IgdGhlIG90aGVyIHRocmVlIHBhZ2VzIHRoYXQgd2lsbCBiZSBtaXNzaW5nLgo8L3A+Cjxicj4KPC90ZD4KPC90cj4KPHRyPgo8dGQ+PHN0cm9uZz5TYW1wbGUgSW5wdXQ8L3N0cm9uZz48L3RkPgo8L3RyPgo8dHI+Cjx0ZD4KPHByZSBjbGFzcz0="brush:java;">12 2 12 9 8 3 0
Sample Output
1 11 12
3 4 10
4 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);
    }
}

      
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
分享到: 
上一篇Codeforces Round #257 (Div. 2)E.. 下一篇Codeforces Round #264 (Div. 2)[..

评论

帐  号: 密码: (新用户注册)
验 证 码:
表  情:
内  容:

·哈希表 - 菜鸟教程 (2025-12-24 20:18:55)
·MySQL存储引擎InnoDB (2025-12-24 20:18:53)
·索引堆及其优化 - 菜 (2025-12-24 20:18:50)
·Shell 中各种括号的 (2025-12-24 19:50:39)
·Shell 变量 - 菜鸟教 (2025-12-24 19:50:37)