Vegetable buy Balloons (Codevs 2851)

Source: Internet
Author: User

Title Description Description

Children's Day arrived, vegetables and vegetables father with vegetables came to the amusement park, vegetables can be happy bad. This is not, the vegetables saw a row of selling balloons, then noisy to buy balloons.

But these balloons are also strange, they are standing in a row, and each time only sell a certain number of balloons, more do not sell, less also do not sell.

Vegetables father has inquired about this n individual each time the number of balloons sold, suddenly want to test vegetables: only from a continuous number of people to buy balloons, and the total number of balloons must be prime, to find the largest number of feasible balloons.

This problem can be puzzled by the vegetables, he found you, ask you to help calculate who to buy from whom, the total number of balloons.

Enter a description Input Description

The first line, a positive integer n.

The second row, n positive integers, the number of I represents the number of balloons that I sell each time ni.

Output description Output Description

A row, three positive integer l,r,s, respectively, to buy the first individual to the R individual balloon, the total number is S, the maximum size required S. In the case of a number of optimal solutions, the output L is the smallest group. Data is guaranteed to be solvable.

Sample input Sample Input

3

1 3 4

Sample output Sample Output

2 3 7

Data range and Tips Data Size & Hint

For 10% of the data, there is 0<n<=20.

For 100% of the data, there is 0<n<=2000,0<ni<=1000.

#include <cstdio>#include<iostream>#defineM 2017#defineN 2017000using namespacestd;intA[m],f[n];voidinit () { for(intI=2; i<n;i++) f[i]=1;  for(intI=2; i<n;i++)      if(F[i]) for(intj=2; i*j<n;j++) F[i*j]=0;}intMain () {init (); intN; scanf ("%d",&N);  for(intI=1; i<=n;i++) {scanf ("%d",&A[i]); A[i]+=a[i-1]; }    intans=0, x, y;  for(intI=1; i<=n;i++)       for(intj=i;j<=n;j++)        if(f[a[j]-a[i-1]]&&a[j]-a[i-1]>ans) {ans=a[j]-a[i-1]; X=i; Y=J; } printf (" %d%d%d", X,y,ans); return 0;}
View Code

Menu for Balloons (Codevs 2851)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.