Xử lý số nguyên lớn

View as PDF

Submit solution


Points: 0.05 (partial)
Time limit: 0.38s
Memory limit: 512M
Input: stdin
Output: stdout

Problem source:
Ðược add lên bởi Võ Khánh Trung
Problem type
Allowed languages
C, C++, Go, Java, Kotlin, Pascal, PyPy, Python, Rust, Scratch

Cho hai số nguyên dương ~A~ và ~B~ ~(A~ & ~B~ có không quá ~1000~ chữ số)

Yêu cầu:

Tính ~A + B~, ~A - B~, ~A \times B~

Input

  • Dòng ~1~: số nguyên ~A~
  • Dòng ~2~: số nguyên ~B~

Output

Output

  • Dòng ~1~: Kết quả ~A + B~
  • Dòng ~2~: Kết quả ~A - B~
  • Dòng ~3~: Kết quả ~A \times B~

Sample Input

10
11

Sample Output

21
-1
110

Note

Chú ý:

  • Khi kết quả là ~0~ các bạn phải in ra ~0~, nếu in ~-0~ là sai
  • Các chữ số ~0~ không có nghĩa ở đầu không được in ra. VD ~013~ thì phải in ra là ~13~, chữ số ~0~ ở đầu không có nghĩa

Comments

Please read the guidelines before commenting.



  • -1
    DAThinh_HuMaDa  commented on Nov. 30, 2025, 5:59 a.m.

    ưu tiên dùng code python cho bài này


  • 0
    sb_anhtuan  commented on Sept. 30, 2025, 3:21 p.m.

    include <bits/stdc++.h>

    using namespace std;

    // Hàm cộng hai số lớn dạng string string addBig(string a, string b) { if (a.size() < b.size()) swap(a, b); int carry = 0; string res = ""; int diff = a.size() - b.size(); for (int i = b.size()-1; i >= 0; i--) { int sum = (a[i+diff]-'0') + (b[i]-'0') + carry; res.pushback(sum % 10 + '0'); carry = sum / 10; } for (int i = diff-1; i >= 0; i--) { int sum = (a[i]-'0') + carry; res.pushback(sum % 10 + '0'); carry = sum / 10; } if (carry) res.push_back(carry+'0'); reverse(res.begin(), res.end()); return res; }

    // (tương tự sẽ viết hàm trừ và nhân)

    int main(){ string a, b; cin >> a >> b; // Nếu làm đầy đủ thì viết addBig(a,b), subBig(a,b), mulBig(a,b). return 0; }


  • -4
    zatarainbow  commented on Dec. 9, 2024, 3:14 a.m.

    a=int(input()) b=int(input()) print(a + b, '\n', a - b, '\n', a * b)


  • -1
    vutuankiet  commented on Sept. 12, 2024, 1:17 p.m.

    tưởng dễ hóa ra bài này khó vậy


  • -9
    kietjumper  commented on Aug. 25, 2024, 5:10 p.m. edited

    This comment is hidden due to too much negative feedback. Show it anyway.


    • -5
      kietjumper  commented on Aug. 27, 2024, 2:53 a.m.

      This comment is hidden due to too much negative feedback. Show it anyway.


  • -5
    melondepchai  commented on July 20, 2024, 9:39 a.m.

    This comment is hidden due to too much negative feedback. Show it anyway.


  • -8
    nhuthenay79  commented on March 6, 2024, 4:45 p.m.

    This comment is hidden due to too much negative feedback. Show it anyway.


  • -14
    coderbiccubing  commented on July 13, 2023, 8:10 a.m.

    This comment is hidden due to too much negative feedback. Show it anyway.


  • -11
    thanhtai0801  commented on Sept. 24, 2022, 6:35 p.m.

    This comment is hidden due to too much negative feedback. Show it anyway.


    • -1
      hothanhdat  commented on Sept. 27, 2022, 2:04 a.m.

      string a,b