Algorithms and Data Structures

  • Profound Academy

    • Status
      • 1
        Implementation
      • 2
        Bitwise operations
      • 3
        Prefix Sums
      • 4
        Sliding window / Two pointers
      • 5
        Modular Arithmetic
      • 6
        Number Theory
      • 7
        Binary Search
      • 8
        Basic Sorting
      • 9
        Greedy Algorithms
      • 10
        Basic Dynamic Programming
      • 11
        Recursion
      • 12
        Linked LIst
      • 13
        Queue & Stack
      • 14
        Binary tree + BST
      • 15
        Divide & Conquer + Advanced Sorting
      • 16
        Heap
      • 17
        Hashing
      • 18
        Graph Representation

  • Simple Division Modulo m

    As calculating division modulo m requires quite involved computations, we are interested in computing the result of division a / b modulo m for only the cases when a is divisible by b.

    Input

    The only line of the input contains 3 integers a (1 ≤ a ≤ ), b (1 ≤ b ≤ ), and m (1 ≤ m ≤ ).

    Output

    If a is divisible by b, the program should print the result of , otherwise, the program should print Impossible.

    Examples

    Input
    Output
    3 8 5
    Impossible
    8 2 3
    1
    6 2 3
    0

    Explanation

    1. 3 is not divisible by 8 ⇒ Impossible
    1. 8 / 2 = 4 ⇒ 4 mod 3 = 1
    1. 6 / 2 = 3 ⇒ 3 mod 3 = 0
     

    Constraints

    Time limit: 1 seconds

    Memory limit: 512 MB

    Output limit: 1 MB

    To check your solution you need to sign in
    Sign in to continue