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 ...
随机推荐
- ID选择器
在很多方面,ID选择器都类似于类选择符,但也有一些重要的区别: 1.为标签设置id="ID名称",而不是class="类名称". 2.ID选择符的前面是井号(# ...
- UIView下使用Animation控制动画
转载自:http://blog.csdn.net/xunyn/article/details/8128031 动画效果是IOS界面重要的特色之一,其中CAAnimation是所有动画对象的抽象父类,作 ...
- 关于alarm函数
#include<unistd.h> #include<signal.h> void handler() { printf("Hello\n"); sign ...
- javascript中的基本数据类型
在javascipt中有五大基本数据类型,列表如下: 1.数字 他们又又包括(正负整数,浮点数)十进制数,十六进制数与八进制数,指数和特殊数值NaN,(Infinity,-Infinity)正负无穷 ...
- NewRowNeeded和UserAddedRow事件以及RowsAdded的区别使用
NewRowNeeded事件当 VirtualMode 属性为 true 时,将在用户定位到 DataGridView 底部的新行时发生,适合给新行建立一些默认数据和按规则应该产生的数据,但此时不推荐 ...
- TatukGIS-TGIS_LayerVector-LocateEx
方法原型: function LocateEx(const _ptg: TGIS_Point; const _prec: Double; const _uid: Integer; var _dist: ...
- css+js自动化开发之第十五天
一.css上一篇的补充 1.position(页面分层) (1)fiexd将标签固定在页面的某个位置 position属性:top,left,right,bottom (2)relative+abso ...
- pytesser的使用
pytesser以及其依赖插件下载地址:链接: http://pan.baidu.com/s/1i3zgpjJ 密码: ueyy 在学习Webdriver的过程中遇到验证码的识别问题,问了度娘知道了p ...
- 弄懂css中单位px和em,rem的区别
国内的设计师大都喜欢用px,而国外的网站大都喜欢用em和rem,那么三者有什么区别,又各自有什么优劣呢? PX特点 1. IE无法调整那些使用px作为单位的字体大小 ...
- 转:jQuery常用插件
原文来自于:http://download.csdn.net/album/detail/369 jquery.cycle.all.js 上传者:itmyhome 上传时间:2014-06-1 ...