fork(1) download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. // exponentiating functions
  5. long long power(long long base, long long exp)
  6. {
  7. long long result = 1;
  8. for (int i = 0; i < exp; ++i) {
  9. result *= base;
  10. }
  11. return result;
  12. }
  13. /*
  14. // recursive version
  15. int rPower(int base, int exp)
  16. {
  17. if (exp == 0)
  18. return 1;
  19.  
  20. return base = base * rPower(base, --exp);
  21. }
  22.  
  23. // ------------------------------------
  24. */
  25.  
  26. int main()
  27. {
  28. int *k = new int;
  29. long long *core = new long long, *eq = new long long, *n = new long long;
  30. *core = 0;
  31.  
  32. cin >> *n >> *k;
  33.  
  34. for (int i = 0; i < *k; ++i) {
  35. *core += 5 * power(10, i);
  36. }
  37.  
  38. *eq = power(10, (*k));
  39. while (*core <= *n) {
  40. *core += *eq;
  41. }
  42.  
  43. cout << *core << endl;
  44.  
  45. delete n; delete k; delete core;; delete eq;
  46. return 0;
  47. }
Success #stdin #stdout 0s 15240KB
stdin
595 
3
stdout
1555