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. if (anteriorRest > 0) {
  15. while (anteriorRest > 0) {
  16. cout << anteriorRest << " ";
  17. ++rezultat[a[0]] = anteriorRest % TEN;
  18. ++counter;
  19. anteriorRest /= TEN;
  20. }
  21. }
  22. rezultat[0] = counter;
  23.  
  24. }
  25. int main() {;
  26. int MAX_SIZE = 1000;
  27. int a[MAX_SIZE + 1], x, rezultat[MAX_SIZE + 1] = {0};
  28. cin >> x;
  29. for (int i = 0; i <= a[0]; ++i) {
  30. cin >> a[i];
  31. }
  32. inmulteste(a, x, rezultat);
  33. return 0;
  34. }
  35.  
  36.  
Success #stdin #stdout 0.01s 5532KB
stdin
3
5 1 2 2 5 8
stdout
2