Problem Statement
Petya likes sequences. He has an infinite sequence A[] with the following properties:
- A[0], A[1], ..., A[N-1] are given;
- A[i]=(A[i-1]+A[i-2]+...+A[i-N])%10 for all i>=N;
Definition
- Class:
- EasySequence
- Method:
- find
- Parameters:
- int[], int[]
- Returns:
- int
- Method signature:
- int find(int[] A, int[] B)
- (be sure your method is public)
Constraints
- A will contain between 1 and 7 elements, inclusive.
- B will contain between 1 and 50 elements, inclusive.
- Each element of A will be between 0 and 9, inclusive.
- Each element of B will be between 0 and 9, inclusive.
Examples
{1,2,3}{0,7,8,5}Returns: 5
Starting with 1,2,3 we have: 1+2+3 = 6, 6 % 10 = 6 2+3+6 = 11, 11 % 10 = 1 3+6+1 = 10, 10 % 10 = 0 6+1+0 = 7, 7 % 10 = 7 1+0+7 = 8, 8 % 10 = 8 0+7+8 = 15, 15 % 10 = 5 7+8+5 = 20, 20 % 10 = 0 1,2,3,6,1,0,7,8,5,0 0,7,8,5 answer = 5{1,2,8}{7,4,2,3}Returns: -1
{1,2,3,4,5}{4,5}Returns: 3
{1}{1,1,1}Returns: 0