Advertisement
Guest User

Untitled

a guest
Oct 16th, 2019
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.75 KB | None | 0 0
  1. #include <iostream>
  2. #include <cmath>
  3. using namespace std;
  4. //formula is n =  and log(q)!=0 and b (q - 1) q (b + m (q - 1))!=0 and c_1 element Z
  5. int main() {
  6.     int a1, b;
  7.     unsigned long long n, MAX;
  8.     scanf("%llu%d%d%llu", &n, &a1, &b, &MAX);
  9.     unsigned long long cur = a1;
  10.     unsigned long long curam = a1;
  11.     unsigned long long plates = n;
  12.     double fplates = 0;
  13.     if (a1 > MAX) {
  14.         printf("0\n");
  15.         return 0;
  16.     }
  17.     if (b == 1) {
  18.         plates = floor(MAX / a1);
  19.         if (plates > n) plates = n;
  20.     }else {
  21.         fplates = (log((MAX * (b - 1)) / a1 + 1)) / log(b);
  22.         fplates = floor(fplates);
  23.         if (fplates > n) fplates = n;
  24.         plates = fplates;
  25.     }
  26.  
  27.  
  28.     printf("%llu", plates);
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement