题目链接:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3365

#include <cstdio>
#include <cmath>
#include <algorithm>
#include <iostream>
#include <cstring>
#include <queue>
#include <vector> #define maxn 50500
#define maxe 11000
#define INF 0x3f3f3f
using namespace std; int a[maxn],b[maxn]; int main(){
//freopen("input.txt","r",stdin);
int n;
while(scanf("%d",&n) == ){
for(int i=;i<=n;i++){
scanf("%d",&a[i]);
b[i] = a[i] - i;
}
sort(b+,b+n+);
int maxnum,renum;
maxnum = ; for(int i=;i<=n;i++){
int num = ;
for(int j=i+;j<=n;j++){
if(b[j] == b[i]) num++;
else{
i = j-;
break;
}
}
if(num > maxnum){ // 这个嵌套有问题,导致WA;
maxnum = num;
renum = b[i];
}
}
printf("%d\n",n-maxnum);
for(int i=;i<n;i++) printf("%d ",renum+i);
printf("%d\n",renum+n);
}
}

zoj 3365 灵活数字规律的更多相关文章

  1. ZOJ 3365 Integer Numbers

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

  2. 数字规律:Pascal‘s triangle

    Given an integer n, return the number of trailing zeroes in n!. Note: Your solution should be in pol ...

  3. 题目1006:ZOJ问题(递推规律)

    题目链接:http://ac.jobdu.com/problem.php?pid=1006 详解链接:https://github.com/zpfbuaa/JobduInCPlusPlus 参考代码: ...

  4. ZOJ 3498 Javabeans(找规律)

    Javabeans Time Limit: 2 Seconds      Memory Limit: 65536 KB Javabeans are delicious. Javaman likes t ...

  5. 剑指offer-字符串&数字规律

    1. 表示数值的字符串 请实现一个函数用来判断字符串是否表示数值(包括整数和小数).例如,字符串"+100","5e2","-123",&q ...

  6. zoj 3365

    题意 给你一个序列  改变尽可能少的数使其成为公差为一 递增的等差数列 可以将给你的序列减去一个等差数列 即num[i] -= i,若得到的数全部相等, 则说明给你的序列本身就满足条件  则只要寻求n ...

  7. 【Ansible】 基于SSH的远程管理工具

    [Ansible] 参考文档:[http://www.ansible.com.cn/docs/intro.html] 和ansible类似的工具还有saltstack,puppet,sshpass等, ...

  8. 剑指Offer:面试题32——从1到n整数中1出现的次数(java实现)

    问题描述: 输入一个整数n,求1到n这n个整数的十进制表示中1出现的次数.例如输入12,从1到12这些整数中包含1的数字有1,10,11,12,1一共出现了5次. 思路:(不考虑时间效率的解法,肯定不 ...

  9. 20160127.CCPP体系详解(0006天)

    程序片段(01):msg.c 内容概要:线程概念 #include <stdio.h> #include <stdlib.h> #include <Windows.h&g ...

随机推荐

  1. HBuilder+移动APP开发实例

    mui: 官网:http://dcloudio.github.io/mui/ 说明:一般要把官网内容通读一遍,这是开发的基础 开始 1.新建项目 在首页点击新建移动App,如下: 或者在项目管理器内右 ...

  2. IIS 64位上發佈32位asp.net設置

    錯誤:無法載入檔案或組件 'Maticsoft.Web' 或其相依性的其中之一. 試圖載入格式錯誤的程式. 解決:新增應用程序池——高級設置——啟用32位應用程式——True

  3. 【BZOJ3211】【并查集+树状数组】花神游历各国

    Description   Input   Output 每次x=1时,每行一个整数,表示这次旅行的开心度 Sample Input 4 1 100 5 5 5 1 1 2 2 1 2 1 1 2 2 ...

  4. nginx location

    1. “= ”,字面精确匹配, 如果匹配,则跳出匹配过程.(不再进行正则匹配) 2. “^~ ”,最大前缀匹配,如果匹配,则跳出匹配过程.(不再进行正则匹配) 3. 不带任何前缀:最大前缀匹配,举例如 ...

  5. 80端口被占用 PID = 4解决办法

    请按照下面的步骤来运行命令:1. sc config http stat = demand2. reboot3. run the command(netsh http show servicestat ...

  6. 那些年被我坑过的Python——摩拳擦掌(第三章)

    集合类型: 集合类型中的元素是唯一的! 集合的定义与赋值: set_1 = set([1, 3, 5, 7, 2]) set_2 = set([2, 4, 6, 8, 3]) 集合的运算操作 # 交集 ...

  7. Why is 0[0] syntactically valid in javascript?

    Why is 0[0] syntactically valid in javascript? 原文链接 偶然在一篇帖子中看到了这个问题,所以打算记录一下. var a = 0[0]; console. ...

  8. Shell 控制并发

    方法1: #!/bin/bash c=0 for i in `seq -w 18 31`;do while [ $c -ge 3 ];do c=$(jobs -p |wc -w) sleep 1s d ...

  9. IIS10 设置支持wcf服务(.svc)

    感谢: http://www.cnblogs.com/dudu/p/3328066.html 如果提示web.config配置重复的话,很有可能是.net framework版本的问题,把IIS中的版 ...

  10. iOS开发工程师笔试题

    iOS开发工程师笔试题 1.   Object-c的类可以多重继承么?可以实现多个接口么?Category是什么?重写一个类的方式用继承好还是分类好?为什么? Object-c的类不可以多重继承:可以 ...