Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cmath>
- using namespace std;
- //formula is n = and log(q)!=0 and b (q - 1) q (b + m (q - 1))!=0 and c_1 element Z
- int main() {
- int a1, b;
- unsigned long long n, MAX;
- scanf("%llu%d%d%llu", &n, &a1, &b, &MAX);
- unsigned long long cur = a1;
- unsigned long long curam = a1;
- unsigned long long plates = n;
- double fplates = 0;
- if (a1 > MAX) {
- printf("0\n");
- return 0;
- }
- if (b == 1) {
- plates = floor(MAX / a1);
- if (plates > n) plates = n;
- }else {
- fplates = (log((MAX * (b - 1)) / a1 + 1)) / log(b);
- fplates = floor(fplates);
- if (fplates > n) fplates = n;
- plates = fplates;
- }
- printf("%llu", plates);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement