fork download
  1. #include <cstdio>
  2.  
  3. using namespace std;
  4.  
  5. const int N = (int)1e5 + 10;
  6.  
  7. int main () {
  8. int n, s;
  9. unsigned long long p[N];
  10.  
  11. scanf("%d %d", &n, &s);
  12.  
  13. p[0] = 1;
  14.  
  15. for(int i = 1; i <= n; i++ ){
  16. int a; scanf("%d", &a);
  17. p[i] = p[i - 1] * (unsigned long long)a;
  18. }
  19.  
  20. unsigned long long ans = 0;
  21.  
  22. for(int i = n; i >= 0; i--) {
  23. ans += (unsigned long long) s / p[i];
  24. s = s % p[i];
  25.  
  26. if (s == 0)
  27. break;
  28. }
  29.  
  30. printf("%llu\n", ans);
  31. return 0;
  32. }
Success #stdin #stdout 0s 4000KB
stdin
Standard input is empty
stdout
0