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 ...
随机推荐
- C# 如何创建接口以及使用接口的简单Demo(转载!)
//No:1 首先,我们要封装一个接口,接口中不要实现具体的方法(说白了这就是一个架子而已!) using System;using System.Collections.Generic;using ...
- maven发布的资源文件到tomcat项目下
问题:项目中有hibernate的资源文件,src/main/java和src/main/resources都有这些文件,当启动项目时发现出错.但是src/main/java已经修改好了, 经查tom ...
- WPF 自定义滚动条样式
先看一下效果: 先分析一下滚动条有哪儿几部分组成: 滚动条总共有五部分组成: 两端的箭头按钮,实际类型为RepeatButton Thumb 两端的空白,实际也是RepeatButton 最后就是Th ...
- What is SaaS?
SaaS, or Software as a Service, describes any cloud service where consumers are able to access softw ...
- Jmeter软件测试2--http接口测试
上次利用Jmeter进行了webservice接口的测试,本次利用Jmeter进行http接口的测试 1.新建线程组 2.新建配置文件 3.新建http请求 4.配置动态请求 4.查看测试结果
- Spring MVC中 controller方法返回值
1.返回ModelAndView 定义ModelAndView对象并返回,对象中可添加model数据.指定view 2.返回String 1.表示返回逻辑视图名 model对象通过 model.add ...
- 13号中断 int 13(转)
第一部分 简 介 1,1 一. 硬盘结构简介 1. 硬盘参数释疑 到目前为止, 人们常说的 ...
- [jQuery编程挑战]007 切换数据表格的行列
<!DOCTYPE html> <html lang="zh"> <head> <meta charset="utf-8&quo ...
- 2基本概念--python深度机器学习
参考彭亮老师的视频教程:转载请注明出处及彭亮老师原创 视频教程: http://pan.baidu.com/s/1kVNe5EJ 基本概念:训练集,测试集,特征值,监督学习,非监督学习,半监督学习,分 ...
- 编译内核出错:invalid option `abi=aapcs-linux' 解决办法
出现此问题的原因是由于kernel feature中选中了Use the ARM EABIto compile the kernel引起的,有两各解决办法: 1)换编译器为arm-linux-gcc ...