问题2916--Dinner is difficult in that world

2916: Dinner is difficult in that world

[命题人 : ]
时间限制 : 5.000 sec  内存限制 : 64 MB

题目描述

Long long ago there was a place, poeple lived there had a strange habit: it's about their dinner. Everyday before they have dinner, they put there food pots in line. They have their own capacity, and every pot is full of food. They choose a trail of successive pots,the total capacity of the trail C must equals k*P+1.(k is an integer P is the population of the tribe). For There is a leader who must get one more than other, and every body except the leader gets the same amount of food. Now, they find it difficult to make sure the start and stop point of the trail. They want you to help them now.

输入

There are multiple test cases. Each test case has two lines. The first line has two integer P(10<=P<=1000000),N(10<=N<=2000000),which indicates the population and the number of food pots. The second line contains N integer which indecate the capacity of every food pot.These integer are between 2 and 100.

输出

One line output for each test case. Shows the start point(S) and stop point(E). So the total capacity from S to E comply with the requirements. If there is multiple solution put the one whose E is smaller, if there's a tie output the one whose S is bigger.

样例输入 Copy

10 10
2 3 4 5 6 7 8 9 10 11 
10 10
9 9 9 9 9 9 6 2 3 5

样例输出 Copy

4 5
2 7

提示

1. pots from 4 to 5 is 5 and 6, their total capacity is 11. 11=10*1+1 2. pots from 2 to 7 is 9 9 9 9 9 6, their total capacity is 51. 51=10*5+1 3. cin might leads to TLE.

来源/分类

tyh