Beruflich Dokumente
Kultur Dokumente
CoSponsors
Expert Level
Time Remaining
4
59
8
Hi RM
A Machine M1 takes a sequence of numbers as input and outputs another sequence. Let
input sequence be x1,x2,,xn. Difference x2x1 is called 1st step difference, x3x2 is
called 2nd step difference ,., xnxn1 is called (n1)th step difference. Thus these step
differences make a new sequence. So, machine M1 calculates these step differences and
outputs this new sequence formed. If input sequence is of length 1 then it just outputs the
input sequence. Now a new Machine M2 is formed which takes a sequence as input and
uses this machine M1 and outputs a sequence. A flag value f is associated with machine
M2 which will be 0 or 1 or 2. Working of machine M2 is shown in the following figure:
We say that Machine M2s output is valid when flag f becomes 2. You have to tell the valid
output of M2 for the given input sequence assuming that when the input was given, flag f
was 0.
Input/Output Specifications
Input Specification:
Input should be sequence of numbers(string) which will be given as an input to machine M2.
Output Specification:
Output should be the valid output(string) of machine M2.
Examples
I am giving the way to find the answer for test case 1. Similarly you can check for the other
test cases. You have to find just the step differences for each new sequence formed by
machine M 1 untill you get the sequence of length 1 (i.e. a number), that number will be the
output.
5
4
-7 1
2
1
0
-11 8
1
-1
-11
19
-7
30 -26 5
-56
31
87
-2
Input: 1,5,9,2,3,5,6
Output: 87
Instructions:
Visit TechGig.com
CPP
CSHARP
JAVA
PHP
VBNET
PYTHON
PERL
RUBY
JS
1 #include<stdio.h>
2 #include<string.h>
3
4 char* sequences(char* input1)
5{
6
//Write code here
7}
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
Position:
Ln 1, Ch 1
Total:
Ln 8, Ch 84
25
Own Testcase
Compile
Submit
Contest Guidelines
Privacy Policy
Sponsors
Contest Terms and Conditions
Referral Terms and Conditions
Join our Social Conversation
Please use the #codegladiators for all your social postings.