Submission #17480842


Source Code Expand

Copy
//#define _GLIBCXX_DEB // Iterator safety; out-of-bounds access for Containers, etc.
//#pragma GCC optimize "trapv" // abort() on (signed) integer overflow.
#include <bits/stdc++.h>

using namespace std;

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

#define ordered_set tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>

#define ll unsigned long long int
#define mod 1000000007
#define deb(x) cout << #x << "=" << x << "\n"
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << "\n"
#define prec(n) fixed << setprecision(n)
#define maxpq priority_queue<int>
#define minpq priority_queue<int, vector<int>, greater<int>>
#define PI 3.1415926535897932384626
#define INF 1000000000
#define no_of_digits(n) floor(log10(n)) + 1
#define bits(n) __builtin_popcount(n)

void solve(){
    ll x, y, a, b, ans = 0;
    cin >> x >> y >> a >> b;
    y--;
    while(x < b / a && x < y){
        x *= a;
        ans++;
    }
    y -= x;
    ans += y / b;
    cout << ans;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
#ifndef ONLINE_JUDGE
    // for getting input from input.txt
    freopen("input1.txt", "r", stdin);
    // for writing output to output.txt
    freopen("output1.txt", "w", stdout);
#endif

    int t = 1;
    //cin >> t;
    while (t--)
    {
        solve();
    }
    return 0;
}

Submission Info

Submission Time
Task D - Takahashi Unevolved
User rohit768
Language C++ (GCC 9.2.1)
Score 400
Code Size 1470 Byte
Status AC
Exec Time 7 ms
Memory 3648 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 400 / 400
Status
AC × 2
AC × 31
Set Name Test Cases
Sample sample_01.txt, sample_02.txt
All hand_01.txt, max_01.txt, max_02.txt, max_03.txt, max_04.txt, max_05.txt, max_06.txt, max_07.txt, max_08.txt, max_09.txt, max_10.txt, max_11.txt, max_12.txt, max_13.txt, max_14.txt, max_15.txt, max_16.txt, random_01.txt, random_02.txt, random_03.txt, random_04.txt, random_05.txt, random_06.txt, random_07.txt, random_08.txt, random_09.txt, random_10.txt, random_11.txt, random_12.txt, sample_01.txt, sample_02.txt
Case Name Status Exec Time Memory
hand_01.txt AC 2 ms 3516 KB
max_01.txt AC 2 ms 3536 KB
max_02.txt AC 5 ms 3520 KB
max_03.txt AC 4 ms 3580 KB
max_04.txt AC 3 ms 3484 KB
max_05.txt AC 3 ms 3484 KB
max_06.txt AC 4 ms 3648 KB
max_07.txt AC 2 ms 3516 KB
max_08.txt AC 2 ms 3532 KB
max_09.txt AC 3 ms 3580 KB
max_10.txt AC 2 ms 3608 KB
max_11.txt AC 3 ms 3536 KB
max_12.txt AC 3 ms 3508 KB
max_13.txt AC 5 ms 3580 KB
max_14.txt AC 2 ms 3508 KB
max_15.txt AC 2 ms 3532 KB
max_16.txt AC 2 ms 3484 KB
random_01.txt AC 2 ms 3484 KB
random_02.txt AC 2 ms 3508 KB
random_03.txt AC 2 ms 3472 KB
random_04.txt AC 3 ms 3608 KB
random_05.txt AC 7 ms 3644 KB
random_06.txt AC 4 ms 3580 KB
random_07.txt AC 5 ms 3636 KB
random_08.txt AC 2 ms 3608 KB
random_09.txt AC 3 ms 3560 KB
random_10.txt AC 2 ms 3580 KB
random_11.txt AC 2 ms 3648 KB
random_12.txt AC 3 ms 3636 KB
sample_01.txt AC 3 ms 3608 KB
sample_02.txt AC 2 ms 3536 KB