Connection Status:
Competition Arena > BigFatInteger2
SRM 599 · 2013-06-25 · by evima · Math
Class Name: BigFatInteger2
Return Type: String
Method Name: isDivisible
Arg Types: (int, int, int, int)
Problem Statement

Problem Statement

This problem statement contains superscipts that may not display properly outside the applet.


You are given four ints A, B, C and D. Return "divisible" (quotes for clarity) if AB is divisible by CD. Return "not divisible" otherwise.

Notes

  • The return value is case-sensitive.
  • Positive integer y divides a positive integer x if and only if there is a positive integer z such that y*z=x. In particular, for each positive integer x, both 1 and x divide x.

Constraints

  • A, B, C and D will each be between 1 and 1,000,000,000 (109), inclusive.
Examples
0)
6
1
2
1
Returns: "divisible"

Here, AB = 61 = 6 and CD = 21 = 2. 6 is divisible by 2.

1)
2
1
6
1
Returns: "not divisible"

2 is not divisible by 6.

2)
1000000000
1000000000
1000000000
200000000
Returns: "divisible"

Now the numbers are huge, but we can see that AB is divisible by CD from the fact that A=C and B>D.

3)
8
100
4
200
Returns: "not divisible"

We can rewrite 8100 as (23)100 = 2300. Similarly, 4200 = (22)200 = 2400. Thus, 8100 is not divisible by 4200.

4)
999999937
1000000000
999999929
1
Returns: "not divisible"

Here A and C are distinct prime numbers, which means AB cannot have C as its divisor.

Submissions are judged against all 323 archived test cases, of which 5 are shown here. Case numbers match the judge’s.

Coding Area

Language: C++17 · define a public class BigFatInteger2 with a public method string isDivisible(int A, int B, int C, int D) · 323 test cases · 2 s / 256 MB per case

Submitting as anonymous