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)