题意 给你一个序列  改变尽可能少的数使其成为公差为一 递增的等差数列

可以将给你的序列减去一个等差数列 即num[i] -= i,若得到的数全部相等, 则说明给你的序列本身就满足条件  则只要寻求num中出现次数最多的数  这些数就是不需要改变的数

/*************************************************************************
> Author: xlc2845 > Mail: xlc2845@gmail.com
> Created Time: 2013年10月26日 星期六 19时15分23秒
************************************************************************/ #include <cstdio>
#include <cstring>
#include <algorithm>
#include <cstdlib> using namespace std;
int num[50050], n;
int main()
{
while(scanf("%d",&n) == 1)
{
for(int i = 0; i < n; i++)
{
scanf("%d",&num[i]);
num[i] -= i;
}
sort(num, num+n);
int temp = num[0], _max = 0, d = 1, result = num[0];
for(int i = 1; i < n; i++)
{
if(num[i] == temp) d++;
else
{
temp = num[i];
if(d > _max)
{
_max = d;
result = num[i-1];
}
d = 1;
}
}
if(d > _max)
{
_max = d;
result = num[n-1];
}
printf("%d\n",n-_max);
printf("%d",result);
for(int i = 1; i < n; i++)
printf(" %d",i+result);
puts("");
}
return 0;
}

zoj 3365的更多相关文章

  1. zoj 3365 灵活数字规律

    题目链接:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3365 #include <cstdio> #incl ...

  2. ZOJ 3365 Integer Numbers

    Integer Numbers Time Limit: 1000ms Memory Limit: 32768KB This problem will be judged on ZJU. Origina ...

  3. TOJ 3365 ZOJ 3232 It's not Floyd Algorithm / 强连通分量

    It's not Floyd Algorithm 时间限制(普通/Java):1000MS/3000MS     运行内存限制:65536KByte   描述 When a directed grap ...

  4. ZOJ People Counting

    第十三届浙江省大学生程序设计竞赛 I 题, 一道模拟题. ZOJ  3944http://www.icpc.moe/onlinejudge/showProblem.do?problemCode=394 ...

  5. ZOJ 3686 A Simple Tree Problem

    A Simple Tree Problem Time Limit: 3 Seconds      Memory Limit: 65536 KB Given a rooted tree, each no ...

  6. ZOJ Problem Set - 1394 Polar Explorer

    这道题目还是简单的,但是自己WA了好几次,总结下: 1.对输入的总结,加上上次ZOJ Problem Set - 1334 Basically Speaking ac代码及总结这道题目的总结 题目要求 ...

  7. ZOJ Problem Set - 1392 The Hardest Problem Ever

    放了一个长长的暑假,可能是这辈子最后一个这么长的暑假了吧,呵呵...今天来实验室了,先找了zoj上面简单的题目练练手直接贴代码了,不解释,就是一道简单的密文转换问题: #include <std ...

  8. ZOJ Problem Set - 1049 I Think I Need a Houseboat

    这道题目说白了是一道平面几何的数学问题,重在理解题目的意思: 题目说,弗雷德想买地盖房养老,但是土地每年会被密西西比河淹掉一部分,而且经调查是以半圆形的方式淹没的,每年淹没50平方英里,以初始水岸线为 ...

  9. ZOJ Problem Set - 1006 Do the Untwist

    今天在ZOJ上做了道很简单的题目是关于加密解密问题的,此题的关键点就在于求余的逆运算: 比如假设都是正整数 A=(B-C)%D 则 B - C = D*n + A 其中 A < D 移项 B = ...

随机推荐

  1. C#中的DateTime:本周第一天,本月第一天,今年第一天,本周第一天的时间

    有时辰需要按照当前时刻,断定其它的都没有什么难度,只是本季度稍稍麻烦些.因为一年有四个季度,可以按照当前月份,获得本季度第一个月的月份,然后这个月的第一天,就是本季度的第一天了 DateTime dt ...

  2. 理解CPU内存管理

    概述:从设计层面理解CPU的内存模式,包括段式内存管理.页式内存管理以及虚拟化扩展内存管理.实际上,硬件支持与软件实现从来就不是能分开讲的,比如,Intel CPU架构师在选择CPU的硬件特性时,必然 ...

  3. Linux msgsnd : invalid argument

    msgsnd(message id, buffer, sizeof buffer, ...); Important: buffer[0]不能为0!!!

  4. iMAC——全新重装Mac系统

    在参考网上重装Mac系统教程的时候,感觉这篇教程挺不错: http://www.iplaysoft.com/osx-yosemite-usb-install-drive.html (此教程终端命令处需 ...

  5. [译]JavaScript检测浏览器前缀

    原文地址: Detect Vendor Prefix with JavaScript 不管浏览器私有前缀的现状如何,我们还是要与之为伴,并且有时候还需要利用它来做一些事情.这些前缀可以用于CSS(比如 ...

  6. javascript笔记——js面试问题

    1:javascript中的变量提升(先使用再声明,js中的函数也存在函数提升) 2:js中的事件捕获和事件冒泡(是两个相反的过程) 3:js中的动画队列(比如animate动画没有在点击的时候阻止正 ...

  7. iptables开始ftp

    如果本机做FTP被访问 iptables -I INPUT -p tcp --dport 21 -m state --state NEW -j ACCEPT //开放21端口iptables -I I ...

  8. 小技巧:SystemTray中进行操作提示

    SystemTray中进行操作提示在wp中应用比较广泛,截图如下. 实现方法也十分简单 1.xaml代码中写入: shell:SystemTray.IsVisible="True" ...

  9. asp.net 时间比较,常用于在某段时间进行操作

    DateTime.Compare(t1,t2)比较两个日期大小,排前面的小,排在后面的大,比如:2011-2-1就小于2012-3-2返回值小于零:  t1 小于 t2. 返回值等于零 : t1 等于 ...

  10. xtraScrollableControl 滚动条随鼠标滚动

    代码如下 // using System; using System.Windows.Forms; using DevExpress.XtraEditors; namespace WindowsFor ...