Beruflich Dokumente
Kultur Dokumente
AUTONCAB|TechGig
Kanahaiya
Search people..
Navigation
Children Problem
Challenge
Time Remaining
57
Challenge Details
49
Prizes
Takers
There are two children harry andRecent
garry. Harry
is having some coins of value a and
garry is having some coins of value b (a and b are positive numbers). They want to get
the greatest common divisor d of a and b by adding or subtracting multiples of these
Leaderboard
Need help
two coins.
let us say that a = 25 and b=45 then their gcd is 5 and 5 = 225 - 45 i.e. gcd can be got
by subtracting one 45 numbered coin from two 25 numbered coins. Your output
should be (2,-1) i.e. you have to find these two multipliers (i.e. d= xa + yb then you
have to output x and y).
Input/Output Specifications
Input Specification:
Input should be the coin values a and b. For the example considered in the question
http://www.techgig.com/assessment/question/MTk3OUAjJEAjJDQzODM3M0AjJEAjJDE5NTI0MjFAIyRAIyQxNDM5OTE2NzU3/1
1/5
8/18/2015
AUTONCAB|TechGig
input is {25,45}.
where 0 <=The value of a and b <=1000
Output Specification:
Output should be {x,y} such that d = gcd(a,b) = xa + yb. For the example considered
in the question output is {2,-1}.
Or
In case of invalid coin value, output will be {0,0}.
Examples
Example 1:
Input: {25,45}
Output: {2,-1}
Explanation-
let us say that a = 25 and b=45 then their gcd is 5 and 5 = 225 - 45 i.e. gcd can be got
by subtracting one 45 numbered coin from two 25 numbered coins.
Your output should be {2,-1} i.e. you have to find these two multipliers (i.e. d= xa +
yb then you have to output x and y).
Example 2:
Input: {-25,45}
Output: {0,0}
Explanation-
One coin value in given input is -ve which is invalid. So the output is {0,0}.
Instructions:
2/5
8/18/2015
AUTONCAB|TechGig
PickyourLanguage
JAVA
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
importjava.io.*;
publicclassCandidateCode
{
publicstaticint[]coins_value(int[]input1)
{
//Writecodehere
}
}
Position:
Ln1,Ch1
OwnTestcase
Compile
Total:
Ln8,Ch131
Submit
Things to do on TechGig
Meet People
Interact with IT industry experts
Assess your skills
Participate in Code Contests
http://www.techgig.com/assessment/question/MTk3OUAjJEAjJDQzODM3M0AjJEAjJDE5NTI0MjFAIyRAIyQxNDM5OTE2NzU3/1
3/5
8/18/2015
AUTONCAB|TechGig
Java
Jobs In Delhi
Android
Jobs In Mumbai
Big Data
Jobs In Chennai
C# Programming
Jobs In Gurgaon
Cloud computing
Jobs In Bangalore
Project Management
Jobs In Noida
Software Testing
Jobs In Hyderabad
All Cities
Jobs by Designation
PHP Jobs
Java Jobs
Oracle Jobs
Asp.Net Jobs
SAP Jobs
MS SQL Jobs
All Skills
All Designation
Browse More
Walkin Jobs
Fresher Jobs
Top Company Jobs
Top Company Pages
Top Skill Pages
Follow TechGig on
SUBSCRIBE
About Us
Contact Us
Privacy Policy
http://www.techgig.com/assessment/question/MTk3OUAjJEAjJDQzODM3M0AjJEAjJDE5NTI0MjFAIyRAIyQxNDM5OTE2NzU3/1
4/5
8/18/2015
AUTONCAB|TechGig
http://www.techgig.com/assessment/question/MTk3OUAjJEAjJDQzODM3M0AjJEAjJDE5NTI0MjFAIyRAIyQxNDM5OTE2NzU3/1
5/5