Problem Description

Bajtek, known for his unusual gifts, recently got an integer array x0,x1,…,xk−1.

Unfortunately, after a huge array-party with his extraordinary friends, he realized that he'd lost it. After hours spent on searching for a new toy, Bajtek found on the arrays producer's website another array aa of length n+1. As a formal description of a says, a0=0 and for all other i (1≤i≤n) ai=x(i−1)mod k+ai−1, where pmodqpmodq denotes the remainder of division p by q.

For example, if the x=[1,2,3] and n=5, then:

a0=0,
a1=x0mod3+a0=x0+0=1,
a2=x1mod3+a1=x1+1=3,
a3=x2mod3+a2=x2+3=6,
a4=x3mod3+a3=x0+6=7,
a5=x4mod3+a4=x1+7=9.
So, if the x=[1,2,3] and n=5, then a=[0,1,3,6,7,9].

Now the boy hopes that he will be able to restore x from a! Knowing that 1≤k≤n, help him and find all possible values of k — possible lengths of the lost array.

Input

The first line contains exactly one integer n (1≤n≤1000) — the length of the array a, excluding the element a0.

The second line contains nn integers a1,a2,…,an (1≤ai≤106).

Note that a0 is always 0 and is not given in the input.

Output

The first line of the output should contain one integer ll denoting the number of correct lengths of the lost array.

The second line of the output should contain ll integers — possible lengths of the lost array in increasing order.

Examples

Input

5
1 2 3 4 5

Output

5
1 2 3 4 5

Input

5
1 3 5 6 8

Output

2
3 5

Input

3
1 5 3

Output

1
2

题意:给出 n 个数以及数组 a,要求出 x 数组的长度,并输出 x 数组

思路:先根据 a 数组将所有 x 数组求出来,然后枚举长度,依次判断是否合法即可

Source Program

#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<cstring>
#include<cmath>
#include<ctime>
#include<algorithm>
#include<stack>
#include<queue>
#include<vector>
#include<set>
#include<map>
#define PI acos(-1.0)
#define E 1e-6
#define MOD 16007
#define INF 0x3f3f3f3f
#define N 1001
#define LL long long
using namespace std;
int a[N];
int sub[N];
int x[N];
int main()
{int n;cin>>n;for(int i=1;i<=n;i++){cin>>a[i];sub[i]=a[i]-a[i-1];}int k=0;for(int i=1;i<=n;i++){bool flag=true;for(int j=i+1;j<=n;j++){if(sub[j]!=sub[j-i]){flag=false;break;}}if(flag){k++;x[k]=i;}}cout<<k<<endl;for(int i=1;i<=k;i++)cout<<x[i]<<" ";cout<<endl;return 0;
}

Lost Array(CF-1043B)相关推荐

  1. C++_STL——array(C++11)

    C++_STL--array(C++11) 1.类模板 template < class T, size_t N > class array; 1.1容器属性 容器属性 序列 序列容器中的 ...

  2. 【解题报告】随便练练二(CF 2300)

    [解题报告]随便练练二(CF 2300) A:Antimatter | CF383D 题意 思路 :DP 代码 B:Physical Education Lessons | CF915E 题意 思路一 ...

  3. Codeforces D. Powerful array(莫队)

    题目描述: Problem Description An array of positive integers a1, a2, ..., an is given. Let us consider it ...

  4. LeetCode算法题-K-diff Pairs in an Array(Java实现)

    这是悦乐书的第254次更新,第267篇原创 01 看题和准备 今天介绍的是LeetCode算法题中Easy级别的第121题(顺位题号是532).给定一个整数数组和一个整数k,您需要找到数组中唯一的k- ...

  5. Commentator problem(CF 2)

    题目链接 题目大意: 给定三个圆,询问是否存在点满足该点与三个圆夹角均相等,若存在多组解返回夹角最大值. 圆外一点到两圆夹角均相等: 即 sina = sinb = r1 / d1 = r2 / d2 ...

  6. C. Three Parts of the Array(切割字符串)

    C. Three Parts of the Array You are given an array d1,d2,-,dnd1,d2,-,dn consisting of nn integer num ...

  7. CF831A-Unimodal Array(单峰阵列)

    A.单峰阵列 Array of integers is unimodal, if: it is strictly increasing in the beginning; after that it ...

  8. 【leetcode】442. Find All Duplicates in an Array(Python C++)

    442. Find All Duplicates in an Array 题目链接 442.1 题目描述: Given an array of integers, 1 ≤ a[i] ≤ n (n = ...

  9. CF817D Imbalanced Array(单调栈)

    CF817D Imbalanced Array 题目传送门 解题思路 根据一位巨佬的题解 枚举当前点在什么区间内是最小值和最大值 可以用四个单调栈 一个找当前点为区间最小值时,区间的最左端(minl) ...

  10. codeforces 361 D. Levko and Array(dp+二分)

    题目链接:http://codeforces.com/contest/361/problem/D 题意:最多可以修改K次数字,每次修改一个数字变成任意值,C=max(a[i+1]-a[i]):求操作之 ...

最新文章

  1. 查询字符串中字母出现的个数
  2. git与eclipse集成之代码冲突与解决
  3. html 商品展示框
  4. [云炬创业学笔记]第二章决定成为创业者测试12
  5. aix 7 oracle 10g,在64位aix上安装oracle10g
  6. Linux安装nginx运行错误,Linux Nginx安装以及可能出现错误
  7. 懒人模式Singleton模式Meyers版本号
  8. 洗头 Wet Hair
  9. iOS字体(UIFont)的相关知识
  10. 计算机组成原理选择题题库
  11. DAS、NAS、SAN三种高端存储技术分析
  12. 公众号600篇文章分类和索引
  13. CCF CSP 公共钥匙盒 JAVA 201709-2 100分
  14. 请在mysql配置文件修sql-mode或sql_mode为NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTIT windows下设置mysql的sql_mode
  15. jSignature 插件实现手写电子签名
  16. H323、H248(MGCP)、SIP三协议浅析
  17. 易语言微凉模块oracle,穿透框架全智能填表微凉网页填表模块及源码
  18. 向周鸿祎学习产品和产品推销方法
  19. 我的第一个JavaScript小游戏--战舰世界
  20. Hive 安装及使用攻略

热门文章

  1. 都9012了,这几个公众号你还没关注?
  2. FreeRTOS任务优先级
  3. Apache Dubbo 3.0.0 正式发布!全面拥抱云原生
  4. 胡润富豪榜2020出炉,雷军身价是任正非的十倍?
  5. H哥被阿里技术的小姐姐采访了,聊了这些东西。
  6. Linux(CentOS)网络流量实时监控(iftop)
  7. Myeclipse8.5 反编译插件 jad 安装
  8. 火热的数据中台对企业的价值是什么?
  9. 常用的前端跨域的几种方式
  10. 微软Kubernetes服务AKS开发正式版空间服务