C++代写:CS20 Karatsuba Algorithm

使用C++完成Karatsuba Algorithm算法的实现。

Karatsuba Algorithm

Task Description

You should carry out this work as a group of 2 students. You should work together but each student has to do their own submission to the websubmission system and marks will be automatically allocated individually.
You are asked to use C++ to implement

  • School Method for Integer Addition
  • Karatsuba Algorithm for Integer Multiplication

Submission Guideline

You must follow this guideline! Your submission will be marked automatically. Failure to follow this guideline will result in 0.
Your submission should contain exactly one file: main.cpp. You do not need to submit a design.

Your program takes one line as input. The input line contains three integers separated by spaces. Let the three integers be “I1 I2 B”. I1 and I2 are both nonnegative integers up to 100 digits long. B represents I1 and I2’s base (B is from 2 to 10).

Your program should output the sum of I1 and I2, using the school method, then the product of I1 and I2, using the Karatsuba algorithm. The results should still use base B. Please separate the results using one space.

Sample input 1: 101 5 10
Sample output 1: 106 505
Sample input 2: 10 111 2
Sample output 2: 1001 1110


Marking will be done automatically. We trust that you’d indeed implement the school method for addition and the Karatsuba algorithm for multiplication. We will randomly pick some submissions to verify whether it is the case. If you use other methods in your submission, it will be considered cheating and you will receive 0.

Submit to Websubmission before the above deadline. The websubmission system for this assignment will be open on 6 August. Websubmission will run an automatic testing script immediately after each submission. Your mark is simply the fraction of test cases that you pass. E.g., if there are 100 test cases, and your code passes 78 of them, then your mark is 78/100. You can submit as many times as you want. The last submission before the deadline will be your “official” submission.

SVN Instructions

First of all, you need to create a directory under version control.
To check out a working copy, type svn checkout.

SVN helps keeping track of file changes (over different commits). You should commit your work early and often.


You are asked to submit via the web interface. The submission steps should be self-explanatory. Simply choose the correct semester, course, and assignment. The websubmission system will automatically fetch the latest version of your work from your SVN repository (you may also choose to submit older versions). Once your work is submitted, the system will launch a script checking the format of your submission. Click “View Feedback” to view the results. You are welcome to resubmit for as many times as you wish (before the deadline).

We will compile your code using g++ -o main.out -O2 -Wall main.cpp. It is your responsibility to ensure that your code compiles on the university system.