21607_Number

2022-5-16 18:19| 发布者: Hocassian| 查看: 27| 评论: 0|原作者: 肇庆学院ACM合集

摘要:
C:\Users\Administrator\Downloads\2019-10-12-10-14-4-89505683110999-Problem List-采集的数据-后羿采集器.html

Pro.ID

21607

Title

Number

Title链接

http://10.20.2.8/oj/exercise/problem?problem_id=21607

AC

0

Submit

0

Ratio

-

时间&空间限制

  • Time Limit: 2000/1000 MS (Java/Others)     Memory Limit: 65536/65536 K (Java/Others)
  • 描述

    Given an equation ( a * x + b ) % n = 0, where a, b, n are positive integers, please find out the least positive integer x make that equation holds.

    输入

    There are several test cases, one line for each case. For each line, there are three positive integers, all of which are no more than 2000000000. Input numbers have no leading zeros. There will be no more than 1000 test cases.

    Input is ended with three 0.

    输出

    Description

    Given an equation ( a * x + b ) % n = 0, where a, b, n are positive integers, please find out the least positive integer x make that equation holds.

    Input

    There are several test cases, one line for each case. For each line, there are three positive integers, all of which are no more than 2000000000. Input numbers have no leading zeros. There will be no more than 1000 test cases.

    Input is ended with three 0.

    Output

    Output each result in one line. Output number must not have any leading zeros. If there is no positive integer makes the equation holds, then output -1.

    Sample Input

    1 1 1
    1 1 2
    1 1 3
    3 4 5
    5 1 5
    0 0 0

    Sample Output

    1
    1
    2
    2
    -1

    Source

    样例输入

    1 1 1
    1 1 2
    1 1 3
    3 4 5
    5 1 5
    0 0 0

    样例输出

    1
    1
    2
    2
    -1

    作者


    路过

    雷人

    握手

    鲜花

    鸡蛋

    最新评论

    返回顶部