23 条题解

  • -2
    @ 2023-11-25 19:48:40

    #include <bits/stdc++.h> using namespace std; int a1[100005], b1[100005], c1[100005], x; int main() { string a,b; cin >> a >> b; int lena = a.size(); int lenb = b.size(); if (lena < lenb || (lena == lenb && a < b)) { swap(lena, lenb); swap(a, b); cout << "-"; } for (int i = 0; i < lena; i++) { a1[i] = a[lena - i - 1] - '0'; } for (int i = 0; i < lenb; i++) { b1[i] = b[lenb - i - 1] - '0'; } int lenc = lena; for (int i = 0; i < lenc; i++) { c1[i] = a1[i] - b1[i]; if (c1[i] < 0) { a1[i + 1]--; c1[i] += 10; } } while (c1[lenc] == 0 && lenc > 0) { lenc--; } for (int i = lenc; i >= 0; i--) { cout << c1[i]; } return 0; }

    信息

    ID
    1191
    时间
    1000ms
    内存
    128MiB
    难度
    6
    标签
    递交数
    913
    已通过
    247
    上传者