zoj 3365 灵活数字规律
题目链接: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 灵活数字规律的更多相关文章
- ZOJ 3365 Integer Numbers
Integer Numbers Time Limit: 1000ms Memory Limit: 32768KB This problem will be judged on ZJU. Origina ...
- 数字规律:Pascal‘s triangle
Given an integer n, return the number of trailing zeroes in n!. Note: Your solution should be in pol ...
- 题目1006:ZOJ问题(递推规律)
题目链接:http://ac.jobdu.com/problem.php?pid=1006 详解链接:https://github.com/zpfbuaa/JobduInCPlusPlus 参考代码: ...
- ZOJ 3498 Javabeans(找规律)
Javabeans Time Limit: 2 Seconds Memory Limit: 65536 KB Javabeans are delicious. Javaman likes t ...
- 剑指offer-字符串&数字规律
1. 表示数值的字符串 请实现一个函数用来判断字符串是否表示数值(包括整数和小数).例如,字符串"+100","5e2","-123",&q ...
- zoj 3365
题意 给你一个序列 改变尽可能少的数使其成为公差为一 递增的等差数列 可以将给你的序列减去一个等差数列 即num[i] -= i,若得到的数全部相等, 则说明给你的序列本身就满足条件 则只要寻求n ...
- 【Ansible】 基于SSH的远程管理工具
[Ansible] 参考文档:[http://www.ansible.com.cn/docs/intro.html] 和ansible类似的工具还有saltstack,puppet,sshpass等, ...
- 剑指Offer:面试题32——从1到n整数中1出现的次数(java实现)
问题描述: 输入一个整数n,求1到n这n个整数的十进制表示中1出现的次数.例如输入12,从1到12这些整数中包含1的数字有1,10,11,12,1一共出现了5次. 思路:(不考虑时间效率的解法,肯定不 ...
- 20160127.CCPP体系详解(0006天)
程序片段(01):msg.c 内容概要:线程概念 #include <stdio.h> #include <stdlib.h> #include <Windows.h&g ...
随机推荐
- 实现多个ContentProvider对多张表进行操作
http://blog.csdn.net/maylian7700/article/details/7365373 SQLite数据库直接操作类: DatabaseHelper.java package ...
- Android 4.0及以上版本接收开机广播BOOT_COMPLETED、开机自启动服务
1.BootCompletedReceiver.Java文件 public class BootCompletedReceiver extends BroadcastReceiver { @Overr ...
- Axis,axis2,Xfire以及cxf对比 (转)
Axis,axis2,Xfire以及cxf对比 http://ws.apache.org/axis/ http://axis.apache.org/axis2/java/core/ http:// ...
- >/dev/null 2>&1 这句话的含义
1表示标准输出,2表示标准错误输出 2>&1表示将标准错误输出重定向到标准输出,这样,程序或者命令的正常输出和错误输出就可以在标准输出输出(也就是一起输出). 一般来讲标准输出和标准错误 ...
- C#堆栈原理(我有两个例子测试你到底会不会)
背景 上次写了一篇文章关于try finnally的一些疑问(被我用windows live覆盖了,草),后来经过大神们解释,我明白了在我理解了try.finnally运行原理后,还欠缺的就是关于值类 ...
- opencv Iplimage结构简介
IplImage 结构解读: typedef struct _IplImage{int nSize; /* IplImage大小 */int ID; ...
- SGU 149. Computer Network
时间限制:0.25s 空间限制:4M: 题意: 给出一颗n(n<=10000)个节点的树,和n-1条边的长度.求出这棵树每个节点到最远节点的距离: Solution: 对于一个节点,我们可以用D ...
- mongo db安装和php,python插件安装
安装mongodb 1.下载,解压mongodb(下载解压目录为/opt) 在/opt目录下执行命令 wget fastdl.mongodb.org/linux/mongodb-linux-x86_6 ...
- C# Winform 双屏显示
双屏显示1 // 利用WinForm中的Screen类,即可比较方便地实现多窗体分别在多个屏幕上显示. //•获取当前系统连接的屏幕数量: Screen.AllScreens.Count(); //• ...
- form WebBrowser自动点击弹出提示框alert、弹出对话框confirm、屏蔽弹出框、屏蔽弹出脚本错误的解决办法
针对WebBrowser控件中自动点击弹出框及禁用脚本提示问题得到如下几种实际情况的解决办法,绝对管用. 1.屏蔽弹出错误脚本 将WebBrowser控件ScriptErrorsSuppressed设 ...