编号 题目 状态 分数 总时间 内存 代码 / 答案文件 提交者 提交时间
#9747 #1070. 脸盲的zzy和jwp Compile Error 0 0 ms 0 K C++ / 858 B lenijwp 2019-07-03 15:01:25
显示原始代码
#include <iostream>
#include <cstdio>
#include <cstring>

using namespace std;

long long Gcd(long long a, long long b) { return b == 0 ? a : Gcd(b, a % b); }

void exGcd(long long a, long long b, long long &x, long long &y) {
    if (b == 0) {
        x = 1;
        y = 0;
        return;
    }
    exGcd(b, a % b, x, y);
    long long tmp = x;
    x = y;
    y = tmp - a / b * y;
}

int main() {
    //  freopen("8.in","r",stdin);
    //    freopen("8.out","w",stdout);
    long long x, y, m, n, L;
    long long a, c, k1, k2, r;
    scanf("%lld%lld%lld%lld%lld", &x, &m, &y, &n, &L) a = n - m;
    c = x - y;
    r = Gcd(a, L);
    if (c % r) {
        puts("-1");
        continue;
    }
    a /= r;
    L /= r;
    c /= r;
    exGcd(a, L, k1, k2);
    long long ans = c * k1 - c * k1 / L * L;
    if (ans < 0)
        ans += L;
    printf("%lld\n", ans);

    return 0;
}

编译信息

/sandbox/1/a.cpp: In function 'int main()':
/sandbox/1/a.cpp:28:49: error: expected ';' before 'a'
     scanf("%lld%lld%lld%lld%lld",&x,&m,&y,&n,&L)
                                                 ^
                                                 ;
         a=n-m; c=x-y;
         ~                                        
/sandbox/1/a.cpp:33:13: error: continue statement not within a loop
             continue;
             ^~~~~~~~
/sandbox/1/a.cpp:28:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%lld%lld%lld%lld%lld",&x,&m,&y,&n,&L)
     ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~