-
-
Save domfarolino/12ff9e31064002e672a4677f5d133b8d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
vector<int> multiplyVectorByInteger(const vector<int>& numVector, int n) { | |
vector<int> returnVec(numVector.size()); | |
int carry = 0; | |
for (int i = 0; i < numVector.size(); ++i) { | |
returnVec[i] = (numVector[i]*n + carry) % 10; | |
carry = (numVector[i]*n + carry) / 10; | |
} | |
while (carry) { | |
returnVec.push_back(carry%10); | |
carry /= 10; | |
} | |
return returnVec; | |
} | |
int main() { | |
vector<int> output = {1}; | |
int n; | |
cin >> n; | |
//.... | |
while (n) { | |
output = multiplyVectorByInteger(output, n); | |
n--; | |
} | |
//.... | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment