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

Input:  Each test case will be described with two integers
N
and P, on a line, where 4 ≤ N ≤ 1000 is a multiple of four that designates the length of the newspaper in terms of numbered pages, and
1 ≤ PN is a page that has been taken. The end of the input is designated by a line containing only the value 0.

Output

Output:  For each case, output, in increasing order, the page numbers for the other three pages that will be missing.

Sample Input
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<stdio.h>
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);
    }
}
时间: 2024-08-27 00:45:24

HNU Missing Pages的相关文章

检查sqlite数据库完整性

最近遇到一个问题,用户数据丢失,拿到用户数据库文件以后,发现数据库损坏. database disk image is malformed 因此希望可以找到一种方法,可以检测出来数据库是否损坏,经过google,找到了一种方法,先记录下来. + (BOOL)checkIntegrity { NSString *databasePath = [self databaseFilePath]; // File not exists = okay if ( ! [[NSFileManager defau

selenium docs

Note to the Reader - Docs Being Revised for Selenium 2.0! Introduction Test Automation for Web Applications To Automate or Not to Automate? Introducing Selenium Brief History of The Selenium Project Selenium’s Tool Suite Choosing Your Selenium Tool S

pestle.phar

命令帮助: php /usr/local/bin/pestle.phar list-commands 查看命令列表 pestle 快速使用参考命令: 生成模块 : php /usr/local/bin/pestle.phar generate_module Mc (verdor) Gtest (module) 0.0.1 生成ACL规则: php /usr/local/bin/pestle.phar generate_acl 生成菜单 : php /usr/local/bin/pestle.ph

恢诡谲怪456风光好风光好

http://i2.feixin.10086.cn/pages/89277/1336279539 http://i2.feixin.10086.cn/pages/89273/1336279551 http://i2.feixin.10086.cn/pages/89282/1336279568 http://i2.feixin.10086.cn/pages/89320/1336279584 http://i2.feixin.10086.cn/pages/89246/1336279591 http:

Page build failed: Missing submodule的解决方案

最近想整理一下工作室官网的东西,那是一个用github pages写的网站,在上传一些post文章的时候,突然给我发邮件说有错误: The page build failed with the following error: The submodule `52FeidianStudio.github.io` was not properly initialized with a `.gitmodules` file. For more information, see https://help

在Oracle 11.2的数据库中建表时遇到 RESULT_CACHE (MODE DEFAULT) ORA-00922: missing or invalid option

在Oracle 11.2的数据库中建表时遇到 RESULT_CACHE (MODE DEFAULT)  ORA-00922: missing or invalid option hostdr:[/home/oracle]$sqlplus / as sysdba SQL*Plus: Release 11.2.0.3.0 Production on Thu Jul 9 12:52:11 2015 Copyright (c) 1982, 2011, Oracle. All rights reserve

The 10 Most Important Security Controls Missing in JavaEE--reference

JavaEE has some excellent built-in security mechanisms, but they don’t come close to covering all the threats that your applications will face.  Many common attacks like Cross-Site Scripting (XSS), SQL Injection, Cross-Site Request Forgery (CSRF), an

Github Pages 代码语法高亮支持的语言和语法分析器

Github Pages 现只支持使用 Rouge 来代码语法高亮了. 从 Rouge 项目 中摘录支持的语言和语法分析器如下,以便查阅. apache: extend previous fix to apache and cmake lexers apiblueprint: Add a lexer for API Blueprint apple_script: utf-8 rampage biml: Initial BIML syntax highlighting support c: mak

The constructor ClassPathXmlApplicationContext(String) refers to the missing type BeansException

"The constructor ClassPathXmlApplicationContext(String) refers to the missing type BeansException" "构造函数ClassPathXmlApplicationContext(字符串)是指缺失类型BeansException" 出现错误的原因:jar没有正确引入,即使表面上你能import包. import org.junit.Test; import org.spring