Sie sind auf Seite 1von 5

8/18/2015

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:

1) Do not write main function.


2) Do not print any variables in the code.
3) You need to return the required output in the given function.
4) Do not change the function and parameter names given in editor code.
http://www.techgig.com/assessment/question/MTk3OUAjJEAjJDQzODM3M0AjJEAjJDE5NTI0MjFAIyRAIyQxNDM5OTE2NzU3/1

2/5

8/18/2015

AUTONCAB|TechGig

5) Return type must be the same as mentioned in the problem statement.


6) When you submit your code, 10 test cases of different complexity will be executed
in the background and marks will be
based on how many of them passed.
7) In case you are not planning to complete the solution in one go, Please save your
code locally in a file as your solution will not be saved when you log out. It will be
saved on Submit.
8 ) You are allowed to submit only two times.

See sample problems & answers

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

Know about top Companies


Read Top Tech News

Follow Skill Pages

Jobs by Top Cities

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 Skill Pages

All Cities

Jobs by Top Skills

Jobs by Designation

PHP Jobs

PHP Developer Jobs

Java Jobs

Java Developer Jobs

Oracle Jobs

Oracle DBA Jobs

Asp.Net Jobs

Network Engineer Jobs

Web Designing Jobs

Linux Administrator Jobs

SAP Jobs

Web Designer Jobs

MS SQL Jobs

SQL Server DBA Jobs

All Skills

All Designation

Browse More
Walkin Jobs
Fresher Jobs
Top Company Jobs
Top Company Pages
Top Skill Pages

Follow TechGig on

TechGig People Directory


ABCDEFGHIJKLMNOPQRSTUVWXYZ

Subscribe for updates from TechGig.com


Enter your email

SUBSCRIBE

TechGig Company Directory


ABCDEFGHIJKLMNOPQRSTUVWXYZ

About Us

Contact Us

Terms & Conditions

Privacy Policy

http://www.techgig.com/assessment/question/MTk3OUAjJEAjJDQzODM3M0AjJEAjJDE5NTI0MjFAIyRAIyQxNDM5OTE2NzU3/1

4/5

8/18/2015

AUTONCAB|TechGig

Copyright Times Business Solutions (A Division of Times Internet Limited) 2015.

http://www.techgig.com/assessment/question/MTk3OUAjJEAjJDQzODM3M0AjJEAjJDE5NTI0MjFAIyRAIyQxNDM5OTE2NzU3/1

5/5

Das könnte Ihnen auch gefallen