Submission #17474821


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;
    cin>>x>>y>>a>>b;
    ll c=0;
    while(x*a<y&&x*a<=(x+b))
    {
        c++;
        x*=a;
    }
    ll z=y-x;
    if(z%b==0)
    c+=(z/b)-1;
    else
    c+=z/b;
    cout<<c;
}
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 0
Code Size 1491 Byte
Status TLE
Exec Time 2205 ms
Memory 3648 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 400
Status
AC × 2
AC × 30
TLE × 1
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 TLE 2205 ms 3264 KB
max_01.txt AC 4 ms 3604 KB
max_02.txt AC 2 ms 3508 KB
max_03.txt AC 3 ms 3544 KB
max_04.txt AC 2 ms 3536 KB
max_05.txt AC 2 ms 3516 KB
max_06.txt AC 2 ms 3512 KB
max_07.txt AC 2 ms 3520 KB
max_08.txt AC 2 ms 3592 KB
max_09.txt AC 2 ms 3600 KB
max_10.txt AC 5 ms 3648 KB
max_11.txt AC 2 ms 3472 KB
max_12.txt AC 3 ms 3524 KB
max_13.txt AC 2 ms 3524 KB
max_14.txt AC 2 ms 3512 KB
max_15.txt AC 2 ms 3592 KB
max_16.txt AC 2 ms 3600 KB
random_01.txt AC 2 ms 3516 KB
random_02.txt AC 2 ms 3600 KB
random_03.txt AC 2 ms 3604 KB
random_04.txt AC 3 ms 3560 KB
random_05.txt AC 2 ms 3476 KB
random_06.txt AC 2 ms 3516 KB
random_07.txt AC 3 ms 3528 KB
random_08.txt AC 2 ms 3628 KB
random_09.txt AC 3 ms 3508 KB
random_10.txt AC 3 ms 3532 KB
random_11.txt AC 4 ms 3560 KB
random_12.txt AC 4 ms 3572 KB
sample_01.txt AC 3 ms 3632 KB
sample_02.txt AC 2 ms 3468 KB