fork(1) download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. void inmulteste(int a[], int x, int rezultat[]) {
  5. const int TEN = 10;
  6. int i = 1, counter = 0, anteriorRest = 0, newRest = 0;
  7. while (i <= a[0]) {
  8. newRest = (a[i] * x + anteriorRest) / TEN;
  9. rezultat[i] = (a[i] * x + anteriorRest) % TEN;
  10. ++counter;
  11. anteriorRest = newRest;
  12. ++i;
  13. }
  14. while (anteriorRest > 0) {
  15. cout << anteriorRest << " ";
  16. ++rezultat[a[0] + 1] = anteriorRest % TEN;
  17. ++counter;
  18. anteriorRest /= TEN;
  19. }
  20.  
  21. rezultat[0] = counter;
  22.  
  23. }
  24. int main() {;
  25. int MAX_SIZE = 1000;
  26. int a[MAX_SIZE + 1], x, rezultat[MAX_SIZE + 1] = {0};
  27. cin >> x;
  28. for (int i = 0; i <= a[0]; ++i) {
  29. cin >> a[i];
  30. }
  31. inmulteste(a, x, rezultat);
  32. return 0;
  33. }
  34.  
  35.  
Success #stdin #stdout 0.01s 5316KB
stdin
19
5 1 2 2 5 8
stdout
16 1