Missing Pages

题目描述

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.

输入

 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 ≤ P ≤ N is a page that has been taken. The end of the input is designated by a line containing only the value 0.

输出

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

示例输入

12  2
12  9
8  3
0

示例输出

1  11  12
3  4  10
4  5  6

提示

 

来源

中国海洋大学第四届朗讯杯高级组


解题报告

开始比赛的时候没去,现在闲着就做做题,英语略过,大概意思就是一张纸有四面,页码就是报纸的形式,看图就会明白,输入页码总数和一个页码,用来输出那个页码所在的纸的其他三个页码数。刚开始没有思路,结果想想用数组来完成,用一个二维数组来表示一份报纸的页码,比如有12页,也就是三页纸,每张纸的页码分别是(1,2,11,12);(3,4,9,10);(5,6,7,8),只要二维数组表示出来就没问题了。结果兴高采烈的提交了,给Presentation Error了,问题很明显,应该是多了空格,输出代码如下

for(i=0;i<4;i++)
    if(x[l][i]!=b)
    {
        printf("%d",x[l][i]);
        if(i!=3)
        printf(" ");
    }
//前面代码略去,x[l][i]表示以储存的报纸页码顺序

修改了空格输出两次,都是PE,就换一种方式,用int数组来储存要输出的页码,就解决问题了

#include<stdio.h>
int main ()
{
    int i,k,l,o,a,b,x[250][4],p,q[3];
    while(scanf("%d",&a)!=EOF)
    {
        if(a==0)break;
        scanf("%d",&b);
        l=1;o=a;p=0;
        for(i=0;i<a/4;i++)
            for(k=0;k<2;k++)
            {
                x[i][k]=l++;
            }
        for(i=i-1;i>-1;i--)
            for(k=2;k<4;k++)
                x[i][k]=l++;
        l=a+1-b;
        for(i=0;i<a/4;i++)
            for(k=0;k<4;k++)
            if(l==x[i][k])
            {
                l=i;
                break;
            }
        for(i=0;i<4;i++)
            if(x[l][i]!=b)
            {
                q[p++]=x[l][i];
            }
        printf("%d %d %d\n",q[0],q[1],q[2]);
  
    }
    return 0;
}




当你在使用DOS系统或相关命令行工具时,可能会遇到“Missing Codepage”的提示。这是一种较为常见的错误提醒,特别是在处理涉及字符集转换的操作时。接下来我会详细解释这一现象及其背后原因,并提供一些解决方案。 ### 什么是Codepage? **Codepage(代码页)** 是计算机用于将特定的字节序列映射到对应的字符集合的一种机制。简单来说,它是一种编码表,规定了每个数值对应显示什么样的文字字符。不同的语言和地区可能需要各自的专用codepages来正确渲染本地化的文本内容。 例如,在简体中文环境下通常会用GBK或者是UTF-8作为标准编码;而在西欧国家则更多倾向于ISO-8859-1或者其他拉丁系别的变种形式。 当提到 "missing codepage" (缺失码表),就意味着当前运行环境缺少必要的配置文件或者支持库以解读来自另一套完全不同体系下的字符串表达式。 ### 可能触发此警告的情形 以下是几种可能导致 “Missing Codepage” 报错的情况: 1. **跨平台迁移数据** 将包含非ASCII字符的数据从一个操作系统复制粘贴到另一个并不兼容其内部默认设定的新主机上面时容易碰到这个问题。 2. **未安装适当的语言包** 某些旧版Windows版本若没有预先加载全部可能需要用到的各种国际间通用的标准字体及关联脚本也可能抛出这种异常消息。 3. **第三方应用程序自带资源不足** 部分独立发行的小型软件本身携带有限数量的基础国际化素材不足以覆盖所有潜在应用场景,因此一旦用户切换至它们未曾考虑过的区域设置便会崩溃告警。 ### 应对策略 针对上述各种可能性分别给出针对性建议如下所示: #### 方法一:检查并更改编码模式 如果是由于输入输出流之间存在差异所造成的误解读现象,那么可以试着通过修改cmd窗口启动参数的方式来强制指定统一使用的charset规则。比如添加chcp指令改变活动console session中的active page number: ```batch CHCP 65001 ; 切换成utf-8 mode under win platform. ``` 同时也要留意目标exe是否接受相应的CLI flags允许手动介入调整locale preferences等方面属性。 #### 方法二:扩充现有runtime capabilities 对于那些因缺乏必要支撑而导致的功能受限情况而言,则可通过下载追加官方提供的补充组件包的形式加以改善优化。典型案列包括但不限于MS Office附赠的日韩汉字补丁包之类的附加产品线延伸服务项目等。 此外还可以探索开源社区贡献出来的免费替代品选项同样能够达到预期效果比如说iconv lib之类的东西可供参考借鉴运用实践中去解决问题所在之处。 --- 以上就是围绕主题展开的相关阐述说明希望对你有所帮助!
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值