编号 题目 状态 分数 总时间 内存 代码 / 答案文件 提交者 提交时间
#21342 #1070. 脸盲的zzy和jwp Wrong Answer 25 30 ms 356 K C++ 17 / 942 B 自动化82-郭筠陶 2020-02-05 15:23:09
显示原始代码
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

ll x, y, a, b, l;
ll exgcd(ll a, ll b, ll& x, ll& y);

int main() {
    cin >> x >> a >> y >> b >> l;
    if (b == a) {
        if (x != y)
            cout << -1;
        else
            cout << 0;
        return 0;
    }
    if (b < a) {
        swap(a, b);
        swap(x, y);
    }
    ll p = b - a, q = ((x - y) + l) % l;
    ll t, k;
    int gcd = exgcd(p, l, t, k);
    if (q % gcd != 0) {
        cout << -1;
    } else {
        ll t0 = t * (q / gcd), q0 = (q / gcd);
        t0 = (t0 % q0 + q0) % q0;
        cout << t0;
    }
}

ll exgcd(ll a, ll b, ll& x, ll& y) {  //扩展欧几里得算法
    if (b == 0) {
        x = 1;
        y = 0;
        return a;  //到达递归边界开始向上一层返回
    }
    int r = exgcd(b, a % b, x, y);
    int temp = y;  //把x y变成上一层的
    y = x - (a / b) * y;
    x = temp;
    return r;  //得到a b的最大公因数
}
子任务 #1
Wrong Answer
得分:25
测试点 #1
Wrong Answer
得分:0
用时:2 ms
内存:272 KiB

输入文件(0.in

6 4 4 2 10

答案文件(0.out

4

用户输出

0

Special Judge 信息

Files user_out and answer differ

系统信息

Exited with return code 0
测试点 #2
Wrong Answer
得分:0
用时:2 ms
内存:352 KiB

输入文件(1.in

28506299 54967377 76257780 18179041 344647755

答案文件(1.out

175111586

用户输出

0

Special Judge 信息

Files user_out and answer differ

系统信息

Exited with return code 0
测试点 #3
Wrong Answer
得分:0
用时:3 ms
内存:356 KiB

输入文件(2.in

89837683 28318386 28926365 27593126 490847831

答案文件(2.out

91595156

用户输出

0

Special Judge 信息

Files user_out and answer differ

系统信息

Exited with return code 0
测试点 #4
Wrong Answer
得分:0
用时:3 ms
内存:284 KiB

输入文件(3.in

7769413 89547256 15137047 64297401 26232361

答案文件(3.out

6586798

用户输出

0

Special Judge 信息

Files user_out and answer differ

系统信息

Exited with return code 0
测试点 #5
Wrong Answer
得分:0
用时:2 ms
内存:280 KiB

输入文件(4.in

62694776 29553013 33500894 25403169 90165477

答案文件(4.out

83740797

用户输出

0

Special Judge 信息

Files user_out and answer differ

系统信息

Exited with return code 0
测试点 #6
Wrong Answer
得分:0
用时:3 ms
内存:352 KiB

输入文件(5.in

52342699 90187177 68103430 71396189 179313475

答案文件(5.out

116043662

用户输出

0

Special Judge 信息

Files user_out and answer differ

系统信息

Exited with return code 0
测试点 #7
Wrong Answer
得分:0
用时:2 ms
内存:296 KiB

输入文件(6.in

1430337 48626001 24961783 8942151 106816817

答案文件(6.out

42763932

用户输出

0

Special Judge 信息

Files user_out and answer differ

系统信息

Exited with return code 0
测试点 #8
Wrong Answer
得分:0
用时:3 ms
内存:348 KiB

输入文件(7.in

17173129 74396504 97129935 68505416 507792673

答案文件(7.out

445951169

用户输出

0

Special Judge 信息

Files user_out and answer differ

系统信息

Exited with return code 0
测试点 #9
Wrong Answer
得分:0
用时:3 ms
内存:292 KiB

输入文件(8.in

6424832 32551261 9136121 98826762 280435157

答案文件(8.out

169591840

用户输出

0

Special Judge 信息

Files user_out and answer differ

系统信息

Exited with return code 0
测试点 #10
Accepted
得分:100
用时:2 ms
内存:304 KiB

输入文件(9.in

22693031 25103341 67212445 51559021 227945004

答案文件(9.out

-1

用户输出

-1

系统信息

Exited with return code 0
测试点 #11
Accepted
得分:100
用时:3 ms
内存:352 KiB

输入文件(10.in

37845999 82853937 302399 56837019 687279423

答案文件(10.out

-1

用户输出

-1

系统信息

Exited with return code 0
测试点 #12
Accepted
得分:100
用时:2 ms
内存:288 KiB

输入文件(11.in

3 2 5 2 10

答案文件(11.out

-1

用户输出

-1

系统信息

Exited with return code 0